python - AttributeError at /login/ 'bool' object has no attribute 'rindex' - Django 1.5 issue -
i'm getting following error in browser everytime try log django app i'm creating:
request method: post request url: http://127.0.0.1:8000/login/ django version: 1.6 #update: have downgraded django 1.5 , still getting error exception type: attributeerror exception value: 'bool' object has no attribute 'rindex' exception location: /library/python/2.7/site-packages/django/core/urlresolvers.py in get_mod_func, line 141 python executable: /usr/bin/python python version: 2.7.2 python path: ['/users/gersande/public/compwebsite/uc', '/library/python/2.7/site-packages/web.py-0.37-py2.7.egg', '/library/python/2.7/site-packages/pymysql-0.5-py2.7.egg', '/system/library/frameworks/python.framework/versions/2.7/lib/python27.zip', '/system/library/frameworks/python.framework/versions/2.7/lib/python2.7', '/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/plat-darwin', '/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/plat-mac', '/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/system/library/frameworks/python.framework/versions/2.7/extras/lib/python', '/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/lib-tk', '/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/lib-old', '/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/lib-dynload', '/system/library/frameworks/python.framework/versions/2.7/extras/lib/python/pyobjc', '/library/python/2.7/site-packages'] server time: fri, 9 aug 2013 00:09:03 -0500
this views.py
, working until recently, , error getting thrown around. have ideas on earth going on?
@csrf_protect @cache_page(60 * 15) def login_user(request): #inactive_image_url = "" #invalid_credentials_url = "" 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!" return render_to_response('uc/portal/index.html', {'state':state, 'username':username}, context_instance=requestcontext(request)) else: state_img = inactive_image_url state = "your account not active, please contact uc admin." else: state_img = invalid_credentials_url state = "your username and/or password incorrect." return render_to_response('uc/index.html', {'state': state, 'state_img': state_img, 'username': username }, context_instance=requestcontext(request)) def portal(request): username = 'username' return render_to_response('uc/portal/index.html', {'username': username, })
edit
this 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('', url(r'^/$','portal.views.index'), url(r'^uc/$', 'portal.views.index'), url(r'^$','portal.views.index'), url(r'^index/$', 'portal.views.index'), # login / logout. url(r'^registration/$', 'portal.views.registration'), url(r'^login/$', 'portal.views.login_user'), url(r'^portal/$', 'portal.views.portal'), # static part of website url(r'^team/$', 'portal.views.team'), url(r'^about/$', 'portal.views.about'),
my configuration file (settings.py) can seen @ http://dpaste.com/1336541/
edit again have downgraded django 1.5, , i'm still getting error. have no idea going on , why login not working. i'm hoping can me figure 1 out, because googling isn't coming useful case , i'm getting frustrated.
the answer in urls.py
notice how in views.py sending correct login return render_to_response('uc/portal/index.html', {'state':state, 'username':username}, context_instance=requestcontext(request))
turns out in urls.py had defined
url(r'^portal/$', 'portal.views.portal'),
but i had not defined uc/portal/index.html
above.
adding url(r'^portal/$', 'portal.views.portal'),
fixed problem entirely
thank bouke taking time me out!!! :d
Comments
Post a Comment