-1

Hello i have a login method in views.py then if i call it from form with post request i have 'module' object has no attribute 'POST' error but as you see i can get form values in traceback. I got form values like that in my before django project. I compared between my old code and this code but i couldn't find my mistake.

enter image description here

enter image description here

enter image description hereenter image description here

1
  • -1 for posting screenshots. Everything you have posted is text, and could be much more easily posted by simply cutting and pasting. Aug 28, 2014 at 18:40

1 Answer 1

1

According to the definition of a django view:

A view function, or view for short, is simply a Python function that takes a Web request and returns a Web response.

request should be passed to the view as an argument, not imported:

def loginUser(request):
    ...

And remove from django.http import * line.

5
  • Problem is solved. But i have one more question. I will code my login system with my old habits from asp.net or php. I will get email and password values then control them in database and i will start user session. Is it true? Aug 28, 2014 at 16:14
  • You should refer this (tangowithdjango.com/book/chapters/login.html) chapter from How to Tango with Django to get an idea. Aug 28, 2014 at 16:20
  • @MertSaygı Good. Take a look at the Authenticating Users documentation paragraph. Also, there are a lot of tutorials and blog posts about building login pages, e.g. tangowithdjango.com/book/chapters/login.html
    – alecxe
    Aug 28, 2014 at 16:20
  • @praba230890 I was pasting the link while you were posting the comment :) Nice timing.
    – alecxe
    Aug 28, 2014 at 16:20
  • I saw this method but this method needs a login view like "url(r'^login/$', views.user_login, name='login')," but i have login form in top of every page. What should i do? Aug 28, 2014 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.