django admin login not redirecting
django, django-admin
Solution
It was actually due to SESSION_COOKIE_SECURE = True in my settings.py, I had it accidentally defined in 2 places, one commented another one uncommented causing that to happen since the site is not running under https yet. It was silly mistake – user1076881 Apr 5 at 7:27
Problem
I am able to browse django admin login page but upon keying in correct login details it will stay on the same login page with empty textboxes. It will show messages if login details are wrong though. I have the following, what ways can I troubleshoot as the log doesn say anything significant. What the ways to test login on the shell? Use manage.py createsuperuser to create superuser as I missed the default one during running syncdb Cleared cookies and retry still the same. Correct SITE_ID in settings.py ``` settings.py import logging import pwd import os DEBUG = True TEMPLATE_DEBUG = DEBUG DEBUG_TOOLBAR = False PROFILER_ON = False INTERNAL_IPS = ( '127.0.0.1' ) ADMINS = ( ('Admin', 'test@domain.com'), ) SEND_BROKEN_LINK_EMAILS = False MANAGERS = ADMINS DEFAULT_FROM_EMAIL = 'test@domain' SERVER_EMAIL = DEFAULT_FROM_EMAIL EMAIL_HOST = 'test' UPLOAD_ROOT = '/domain/uploads' PUBLIC_UPLOAD_ROOT = '/domain/htdocs/public_uploads' DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'table_name', 'USER': 'username', 'PASSWORD': 'password', 'HOST': 'localhost', 'PORT': '', # use this to create InnoDB tables 'OPTIONS': { 'init_command': 'SET storage_engine=InnoDB', 'charset': 'utf8', } } } #SESSION_COOKIE_SECURE = True # Setup logging LOGGING = { 'version': 1, 'disable_existing_loggers': True, } TIME_ZONE = 'America/Chicago' LANGUAGE_CODE = 'en-us' LANGUAGES = ( ('en-us', _('English(US)')), ) SITE_ID = 1 SITE_NAME = 'my site' USE_I18N = True MEDIA_ROOT = os.path.join(os.path.dirname(__file__), 'media') MEDIA_URL = '/media/' PUBLIC_UPLOAD_URL = '/public_uploads/' UPLOAD_URL = '/uploads/' UPLOAD_IMAGES_DIR = 'images/' ADMIN_MEDIA_PREFIX = '/djangomedia/' SECRET_KEY = 'test' #SESSION_COOKIE_HTTPONLY = True #SESSION_COOKIE_DOMAIN = 'domain' # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', ) MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.transaction.TransactionMiddleware', 'django.middleware.doc.XViewMiddleware', 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware', ) LOGIN_URL = '/login/' LOGIN_REDIRECT_URL = '/users/main/' # The URL where requests are redirected for logout. LOGOUT_URL = '/logout/' TEMPLATE_CONTEXT_PROCESSORS = ( 'django.contrib.auth.context_processors.auth', 'django.core.context_processors.i18n', 'django.core.context_processors.request', 'django.contrib.messages.context_processors.messages', ) AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.ModelBackend', ) ROOT_URLCONF = 'myapp.urls' TEMPLATE_DIRS = ( os.path.join(os.path.dirname(__file__), 'templates'), ) INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.admin', 'django.contrib.admindocs', 'django.contrib.flatpages', ) urls.py url(r'^admin/', include(admin.site.urls)), ```