2
votes

I'm making a pretty simple Django app and I cant get the Admin site to behave...

Symptoms

  • the url .../admin/ shows me the expected login form
  • if I fill in the form incorrectly I get relevant error messages
  • if I fill in the form correctly with the details of a superuser (created via manage.py createsuperuser) then the page does not redirect or come up with errors
  • using the shell I can successfully authenticate the user I was trying to log in with
  • examining the auth_user database table, is_staff, is_avctive, and is_superuser are all set to 1
  • if I go to the admin login and attempt to login then the server console output looks fine:

    [25/Jan/2013 06:27:28] "GET /admin/ HTTP/1.1" 200 2028
    [25/Jan/2013 06:27:34] "POST /admin/ HTTP/1.1" 302 0
    [25/Jan/2013 06:27:34] "GET /admin/ HTTP/1.1" 200 2028
    

Configuration:

In my settings file I have:

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin', ...

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
)

I haven't changed from the default authentication backend

In my url config I have:

from django.contrib import admin
admin.autodiscover()
.......
url(r'^admin/', include(admin.site.urls)),

I'm running django 1.3.1 and Python 2.7

Question:

How can I fix this? What am I missing?

1
My first guess would be cookies. Check if your browser sends cookies correctly. And that they persists between requests (e.g. you don't have settings to store cookies in phony cache).alex vasi
does it work in other browsers?Marat
@alexvasi: My cookie settings look fine to me and have never given me issues on other sitesSheena
@Marat: I've tried Firefox and Chromium... both do the same thingSheena
is there anything unusual at development server output? Can you check the DB queries (you can get them by using django-debug-toolbar)?Marat

1 Answers

1
votes

My problem was that SESSION_COOKIE_SECURE was set to True.

Thanks all for your comments