Django Admin Login - Redirecting back to login page

5,896 views
Skip to first unread message

Aidan

unread,
Jun 6, 2011, 6:57:11 AM6/6/11
to Django users
I'm having trouble with the Django Admin. My login page appears ok at
http://127.0.0.1:8000/admin but when I try to login with a valid
username or password the page seems to refresh - it reappears with
text boxes empty. It doesn't display any errors on the page (logging
in with invalid username / password brings up all the red errors you'd
expect).

I'm not sure what's going on here. The console gives me the following:

(cache) C:\PythonProjects\CacheProject\cache>python manage.py
runserver
Validating models...

0 errors found
Django version 1.3, using settings 'cache.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[06/Jun/2011 11:52:09] "GET /admin/ HTTP/1.1" 200 2053
[06/Jun/2011 11:52:17] "POST /admin/ HTTP/1.1" 302 0
[06/Jun/2011 11:52:21] "GET /admin/ HTTP/1.1" 200 2053

settings.py -
#
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
)
#

urls.py -

from django.conf.urls.defaults import patterns, include, url

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
(r'^admin/', include(admin.site.urls)),
)

Any ideas?

Martin

unread,
Jun 6, 2011, 7:13:34 AM6/6/11
to django...@googlegroups.com
I faced this a long time ago and it nearly drove me insane. Eventually I just started a new project from scratch and the problem disappeared.

Wild guesses:

  • Open the JavaScript debug toolbar of Google Chrome (CTRL+SHIFT+J), then reload the site and see if there are any 404 errors (that means your static / media files are not served correctly)
  • Refresh your browers cache, restart the browser and try again
  • delete your database and run a fresh syncdb --all
Best regards,
Martin


--
You received this message because you are subscribed to the Google Groups "Django users" group.
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.


Martin

unread,
Jun 6, 2011, 7:15:05 AM6/6/11
to django...@googlegroups.com
Oh and:
  • delete all *.pyc files from your project and restart the development server <-- this is a nice one that often solves mysterious problems that seem to be impossible and drive you insane
Best regards,
Martin

Karen Tracey

unread,
Jun 6, 2011, 7:19:57 AM6/6/11
to django...@googlegroups.com
On Mon, Jun 6, 2011 at 6:57 AM, Aidan <aida...@gmail.com> wrote:
I'm having trouble with the Django Admin. My login page appears ok at
http://127.0.0.1:8000/admin but when I try to login with a valid
username or password the page seems to refresh - it reappears with
text boxes empty. It doesn't display any errors on the page (logging
in with invalid username / password brings up all the red errors you'd
expect).

I have seen this (though not with admin -- with a custom site login form) when somehow two sessionid cookies have been set. Using the browser tools to delete the sessionid cookies and try again allows login. I don't believe we've tracked down yet how the multiple sessionid cookies are getting set.

Karen
--
http://tracey.org/kmt/

Aidan

unread,
Jun 6, 2011, 8:33:27 AM6/6/11
to Django users
Thanks for the input.

I've tried deleting all .pyc files and still get the same issue.

Also checked the cookies - I've got one sessionid and one csrftoken,
so that doesn't look like the issue.

I've tried using the chrome javascript debugger to look for 404's and
haven't found any.

I haven't deleted the database yet as there's data used (by South), to
do migrations on the tables underneath my models. I don't want to have
to recreate it all.

On Jun 6, 12:19 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> On Mon, Jun 6, 2011 at 6:57 AM, Aidan <aidane...@gmail.com> wrote:
> > I'm having trouble with the Django Admin. My login page appears ok at
> >http://127.0.0.1:8000/adminbut when I try to login with a valid

Aidan

unread,
Jun 6, 2011, 11:54:48 AM6/6/11
to Django users
Have commented out the 'SESSION_COOKIE_SECURE' and
'SESSION_EXPIRE_AT_BROWSER_CLOSE' from the settings.py file.

This has fixed the problem and I can now log in to admin.

On Jun 6, 1:33 pm, Aidan <aidane...@gmail.com> wrote:
> Thanks for the input.
>
> I've tried deleting all .pyc files and still get the same issue.
>
> Also checked the cookies - I've got one sessionid and one csrftoken,
> so that doesn't look like the issue.
>
> I've tried using the chrome javascript debugger to look for 404's and
> haven't found any.
>
> I haven't deleted the database yet as there's data used (by South), to
> do migrations on the tables underneath my models. I don't want to have
> to recreate it all.
>
> On Jun 6, 12:19 pm, Karen Tracey <kmtra...@gmail.com> wrote:
>
>
>
>
>
>
>
> > On Mon, Jun 6, 2011 at 6:57 AM, Aidan <aidane...@gmail.com> wrote:
> > > I'm having trouble with the Django Admin. My login page appears ok at
> > >http://127.0.0.1:8000/adminbutwhen I try to login with a valid

Діма Ревуцький

unread,
Jun 24, 2014, 10:40:11 AM6/24/14
to django...@googlegroups.com
I had same problem 
In settings remove SESSION_COOKIE_DOMAIN or set correct domain

понедельник, 6 июня 2011 г., 13:57:11 UTC+3 пользователь Aidan написал:

Sergiy Khohlov

unread,
Jun 24, 2014, 10:55:21 AM6/24/14
to django-users
Hello,

 Could you please paste your LOGIN_URL  from your settings.py



Many thanks,

Serge


+380 636150445
skype: skhohlov


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.

Aaron Reabow

unread,
Jun 24, 2014, 12:49:19 PM6/24/14
to django...@googlegroups.com
also try: LOGIN_REDIRECT_URL
Reply all
Reply to author
Forward
0 new messages