python - Django auth app - only one argument being given to login(), which takes two arguments -


i'm working in django first time , far it's been hopping error error, forcing me pay attention i'm doing. there's issue has been bugging me quite bit.

i'm getting following error in browser:

typeerror @ /login/ login() takes 2 arguments (1 given) request method: post request url:    http://127.0.0.1:8000/login/ django version: 1.6 exception type: typeerror exception value:     login() takes 2 arguments (1 given) 

when take @ code in views.py takes care of authenticate() , login() functions, i've got following code:

@cache_page(60 * 15) def login_user(request):     context_instance=requestcontext(request)     if request.post:         username = request.post.get['username']         password = request.post.get['password']         user = authenticate(username=username, password=password)         if user not none:             if user.is_active:                 login(request, user)                             state = "you're logged in!"             else:                 state = "your account not active, please contact site admin."         else:             state = "your username and/or password incorrect."     return render_to_response('undercovercoders/index.html', {'state':state, 'username':username}, context_instance=requestcontext(request)) 

i using official docs create if/else loop there, why is not being defined? because authenticate() returning nothing? shouldn't mean website returns error state? thank helping, let me know if there's can add!

edit

my urls.py

from django.conf.urls import patterns, include, url django.conf import settings django.conf.urls.static import static django.conf.urls import *  # uncomment next 2 lines enable admin: # django.contrib import admin # admin.autodiscover()      urlpatterns = patterns('',     (r'^/$','portal.views.index'),     (r'^$','portal.views.index'),    # login / logout.  (r'^registration/$', 'portal.views.registration'), (r'^login/$', 'portal.views.login'), (r'^dashboard/$', 'portal.views.dashboard'), (r'^team/$', 'portal.views.team'), (r'^about/$', 'portal.views.about'), (r'^parents/$', 'portal.views.parents'), (r'^legal/$', 'portal.views.legal'), (r'^index/$', 'portal.views.index'), 

see how have:

(r'^login/$', 'portal.views.login'), 

but view called login_user.

replace line above

(r'^login/$', 'portal.views.login_user'), 

your /login/ url calling django.auth.login method instead of view.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -