[Answer]-Request.POST.get [] is empty

0πŸ‘

βœ…

I recommend to check the documentation about this topic, you will find a lot of important notes too. You can use inbuilt login view – django.contrib.auth.views.login to handle authentication stuff for you but you have to prepare the template.

If the given POST variable is empty, you didn’t submitted the variable in your form so check your html code in tools like Firebug

1πŸ‘

It seems to be you are trying to perform an authentication in your view. You can use @login_required decorator. More info at
https://docs.djangoproject.com/en/dev/topics/auth/default/#the-login-required-decorator

0πŸ‘

I’m not sure I understand what it is you’re trying to do. If you’re trying to get details of the user in your django view then you can use request.user. eg

def your_view(request):
    #...
    user = request.user
    return render(request, 'your_page.html')

Have a look at the user auth docs.

Leave a comment