login auth issue - beginner

169 views
Skip to first unread message

Phil

unread,
Aug 20, 2011, 9:59:22 AM8/20/11
to django...@googlegroups.com
Hi, 

I am new to Django and am trying to use the built in auth features for the first time. I have been following the steps on the djangobook website here... 

http://www.djangobook.com/en/1.0/chapter12/ 

However I am getting the following error on my login page. Anyone know where I am going wrong?... 


Environment: 


Request Method: GET 
Request URL: http://127.0.0.1:8080/login/ 

Django Version: 1.3 
Python Version: 2.7.1 
Installed Applications: 
['django.contrib.auth', 
'django.contrib.contenttypes', 
'django.contrib.sessions', 
'django.contrib.sites', 
'django.contrib.messages', 
'django.contrib.staticfiles', 
'django.contrib.admin', 
'django.contrib.admindocs', 
'healthapp', 
'healthapp.myhealth'] 
Installed Middleware: 
('django.middleware.common.CommonMiddleware', 
'django.contrib.sessions.middleware.SessionMiddleware', 
'django.middleware.csrf.CsrfViewMiddleware', 
'django.contrib.auth.middleware.AuthenticationMiddleware', 
'django.contrib.messages.middleware.MessageMiddleware') 


Traceback: 
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response 
111. response = callback(request, *callback_args, **callback_kwargs) 
File "/home/phil/mydev/projects/healthapp/../healthapp/views.py" in login 
16. username = request.POST['username'] 
File "/usr/local/lib/python2.7/dist-packages/django/utils/datastructures.py" in __getitem__ 
256. raise MultiValueDictKeyError("Key %r not found in %r" % (key, self)) 

Exception Type: MultiValueDictKeyError at /login/ 
Exception Value: "Key 'username' not found in <QueryDict: {}>" 

Phang Mulianto

unread,
Aug 20, 2011, 10:15:07 AM8/20/11
to django...@googlegroups.com
hi.. your request is  GET, and you try get the query data with POST .

this the errror cause 
16. username = request.POST['username']    

Exception Value: "Key 'username' not found in <QueryDict: {}>" 

check your login form to use POST..

HTH,

Mulianto


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/9zw1FCvQ33kJ.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Message has been deleted

Phil

unread,
Aug 20, 2011, 10:32:36 AM8/20/11
to django...@googlegroups.com
Thanks for reply. 

Yes my form is using POST. Here is my template file...

{% block content %}

  {% if form.errors %}
    <p class="error">Sorry, that's not a valid username or password</p>
  {% endif %}

  <form action='/' method='POST'>
    <label for="username">User name:</label>
    <input type="text" name="username" value="" id="username">
    <label for="password">Password:</label>
    <input type="password" name="password" value="" id="password">

    <input type="submit" value="login" />
    <input type="hidden" name="next" value="{{ next|escape }}" />
  </form>

{% endblock %}

dm03514

unread,
Aug 20, 2011, 10:46:07 AM8/20/11
to Django users
Hi, Your traceback is from a 'login' function buy you're posting to
base '/'
Could that be an issue??
The traceback clearly explains what the problem is, no data is
arriving at your login function
Reply all
Reply to author
Forward
0 new messages