Django Admin panel not working with https
Question: I have a Django project which I just deployed using Apache and mod_wsgi, which
seemed to be working perfectly. I then changed the Apache config file to allow
HTTPS and now my admin site is not working (though the regular site does work
with both http and https).

First, if I go to <http://www.example.com/admin> or
<https://www.example.com/admin>, I get "Server Error (500)". There is nothing
listed in my Apache error log but I get the following line in
other_vhosts_access.log:

With HTTPS:

    
    
    "GET /admin/login/?next=/admin/ HTTP/1.1" 500 553 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36"
    

With HTTP:

    
    
    "GET /admin/login/?next=/admin/ HTTP/1.1" 500 300 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36"
    

Second, if I login to www.example.com using my admin username and password AND
THEN go to www.example.com/admin I get the standard admin panel (if I use
HTTP) or I get the admin panel minus any CSS (when I use HTTPS).

Here is my current Apache config file (EDITED to add missing /static alias):

    
    
    <VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName www.example.com
        ServerAlias www.example.com
        DocumentRoot /srv/www/www.example.com
    
        Alias /static /srv/www/www.example.com/static
        <Directory /srv/www/www.example.com/static>
            Order allow,deny
            Allow from all
        </Directory>
    
        <Directory /srv/www/www.example.com/my_app>
            <Files wsgi.py>
                Allow from all
            </Files>
        </Directory>
    
        WSGIDaemonProcess my_app python-path=/srv/www/bcsurvey.wwbp.org:/srv/www/www.example.com/virtenv/lib/python2.7/site-packages
        WSGIProcessGroup my_app
        WSGIScriptAlias / /srv/www/www.example.com/my_app/wsgi.py
     </VirtualHost>
    
     NameVirtualHost *:443
     <VirtualHost *:443>
        SSLEngine on
        SSLCertificateFile    /etc/apache2/sslkey/mykey.crt
        SSLCertificateKeyFile /etc/apache2/sslkey/mykey.crt
    
        ServerAdmin webmaster@localhost
        ServerName www.example.com
        ServerAlias www.example.com
        DocumentRoot /srv/www/www.example.com
    
        WSGIProcessGroup my_app
        WSGIScriptAlias / /srv/www/www.example.com/my_app/wsgi.py
    
        Alias /static /srv/www/www.example.com/static
        <Directory /srv/www/www.example.com/static>
            Order allow,deny
            Allow from all
        </Directory>
    
        <Directory /srv/www/www.example.com/my_app>
            <Files wsgi.py>
                Allow from all
            </Files>
        </Directory>
     </VirtualHost>
    

Here is my settings.py file:

    
    
     import os
     BASE_DIR = os.path.dirname(os.path.dirname(__file__))
    
     TEMPLATE_PATH = os.path.join(BASE_DIR, 'templates')
     STATIC_PATH = os.path.join(BASE_DIR, 'static')
     STATIC_ROOT = '/srv/www/www.example.com'
     MEDIA_PATH = os.path.join(BASE_DIR, 'media')                                                                                                             
    
     # SECURITY WARNING: keep the secret key used in production secret!                                                                                                                   
     SECRET_KEY = 'mykey'
    
     # SECURITY WARNING: don't run with debug turned on in production!                                                                                                                    
     DEBUG = False
    
     TEMPLATE_DEBUG = True
    
     ALLOWED_HOSTS = ['www.example.com']
    
     INSTALLED_APPS = (
         'django.contrib.admin',
         'django.contrib.auth',
         'django.contrib.contenttypes',
         'django.contrib.sessions',
         'django.contrib.messages',
         'django.contrib.staticfiles',
         'django.contrib.sites',
         'survey',
     )
    
     MIDDLEWARE_CLASSES = (
         'django.contrib.sessions.middleware.SessionMiddleware',
         'django.middleware.common.CommonMiddleware',
         'django.middleware.csrf.CsrfViewMiddleware',
         'django.contrib.auth.middleware.AuthenticationMiddleware',
         'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
         'django.contrib.messages.middleware.MessageMiddleware',
         'django.middleware.clickjacking.XFrameOptionsMiddleware',
     )
    
     ROOT_URLCONF = 'my_app.urls'
    
     WSGI_APPLICATION = 'my_app.wsgi.application'
    
     DATABASES = {
         'default': {
         'ENGINE': 'django.db.backends.sqlite3',
             'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
         }
     }
    
     LANGUAGE_CODE = 'en-us'
     TIME_ZONE = 'UTC'
     USE_I18N = True
     USE_L10N = True
     USE_TZ = True                                                                                                                       
    
     STATIC_URL = '/static/'
     STATICFILES_DIRS = (
         STATIC_PATH,
     )
    
     MEDIA_URL = '/media/'
     MEDIAFILES_DIRS = (
         MEDIA_PATH,
     )
    
     TEMPLATE_DIRS = (
         TEMPLATE_PATH,
     )
    
     EMAIL_USE_TLS = True
     EMAIL_HOST = 'smtp.email.com'
     EMAIL_PORT = 587
     EMAIL_HOST_USER = 'myemail@email.com'
     EMAIL_HOST_PASSWORD = 'myemailpassword'
     DEFAULT_FROM_EMAIL = 'myemail@email.com'
     DEFAULT_TO_EMAIL = 'to email'
    

Also, I am using Django v. 1.7.


Answer: **Edit:** Real error was the missing **SITE_ID** setting. See comments for out
little debug session...

_Original answer:_ You're missing the /static Alias in your https config.

Are the static assets requested by https?

Additionally, you're missing the WSGIDaemonProcess statement in your https
config.

