title: Django Admin panel not working with https
body: <p>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).</p>
  
  <p>First, if I go to <a href="http://www.example.com/admin" rel="nofollow">http://www.example.com/admin</a> or <a href="https://www.example.com/admin" rel="nofollow">https://www.example.com/admin</a>, 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:</p>
  
  <p>With HTTPS:</p>
  
  <pre><code>"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"
  </code></pre>
  
  <p>With HTTP:</p>
  
  <pre><code>"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"
  </code></pre>
  
  <p>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). </p>
  
  <p>Here is my current Apache config file (EDITED to add missing /static alias): </p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
      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
      &lt;Directory /srv/www/www.example.com/static&gt;
          Order allow,deny
          Allow from all
      &lt;/Directory&gt;
  
      &lt;Directory /srv/www/www.example.com/my_app&gt;
          &lt;Files wsgi.py&gt;
              Allow from all
          &lt;/Files&gt;
      &lt;/Directory&gt;
  
      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
   &lt;/VirtualHost&gt;
  
   NameVirtualHost *:443
   &lt;VirtualHost *:443&gt;
      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
      &lt;Directory /srv/www/www.example.com/static&gt;
          Order allow,deny
          Allow from all
      &lt;/Directory&gt;
  
      &lt;Directory /srv/www/www.example.com/my_app&gt;
          &lt;Files wsgi.py&gt;
              Allow from all
          &lt;/Files&gt;
      &lt;/Directory&gt;
   &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>Here is my settings.py file:</p>
  
  <pre><code> 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'
  </code></pre>
  
  <p>Also, I am using Django v. 1.7. </p>