Error when redirecting after login in Django 1.2
I've been getting this error:
The requested admin page does not exist.
I've got a view at the URL /members/
which is protected by @login_required
. When I'm not logged-i开发者_运维问答n and visit the /members/
URL, I get redirected to:
http://127.0.0.1:8000/admin/login/?next=/members/
When I enter my login credentials and click "Log in", I get that error (only when DEBUG
is True
, otherwise I get a 404), and I'm still at the address:
http://127.0.0.1:8000/admin/login/?next=/members/
Some comments I've found about this seem to be to do with the order in which I add bits to my urlpatterns
, but that doesn't seem to make any difference.
Any other ideas?
My urls.py
looks roughly like this:
urlpatterns = patterns('',
(r'^$', 'myproject.views.homepage', {}, 'homepage'),
# some other stuff
)
urlpatterns += patterns('',
(r'^members/', include('members.urls', namespace = u'members', app_name = u'members')),
)
urlpatterns += patterns('',
(r'^admin/', include(admin.site.urls)),
)
Let me know if there's anything else that might help me work out what's wrong!
Is there a reason why your user login URL is the same as the admin app's login URL? Is this by design?
Originally there was only the admin app that needed a login. This is my first foray on this project into non-admin login_required views. I will move this soonish - could this be causing the problem?
Looks like that is the case, though I don't know the details. I tried it out in one of my projects http://localhost:8000/admin/login/?next=/valid_url/
and got the same error.
Solution: use a different view for user login.
精彩评论