2

Originally when I installed Django 1.3 with wsgi on my ubuntu server I used the included setup.py file and so when I wanted to update followed the Remove any old versions of Django section of the install guide by renaming the "django" folder in my site-packages "django.old" and then installing the new version by using the the setup.py file for Django 1.4

After restarting my apache server I got a standard 500 Internal error. I checked the apache error log and discovered that ADMIN_MEDIA_PREFIX has been deprecated so following the Django 1.4 release notes I removed ADMIN_MEDIA_PREFIX from the settings file and moved the admin files into the static directory under a folder called "admin" as indicated.

I restarted my apache server again and received the same standard 500 error but this time when I tried running a tail on the apache error log no new errors registered.

Without any further error messages I am really stuck so any help will be appreciated.

Below is the content of my apache site config file and the wsgi file

site config:

<VirtualHost *:80>
    ServerAdmin me@mysite.com
    ServerName  www.mysite.com
    ServerAlias mysite.com

    # Indexes + Directory Root.
    # DirectoryIndex index.html index.htm index.php
    DocumentRoot /home/www/www.mysite.com/htdocs/

    # CGI Directory
    ScriptAlias /cgi-bin/ /home/www/www.mysite.com/cgi-bin/
    <Location /cgi-bin>
            Options +ExecCGI
    </Location>

    # Logfiles
    ErrorLog  /home/www/www.mysite.com/logs/error.log
    CustomLog /home/www/www.mysite.com/logs/access.log combined

    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /home/www/www.mysite.com/htdocs/>
            Options FollowSymLinks MultiViews
            AllowOverride All
           allow from all
    </Directory>

    ### Connect Django to the URL using WSGI (the django recommended method)
    WSGIScriptAlias /myproject /django/myproject/django.wsgi

    ### Alias to the location of the static dir (images, css, js etc.)
    Alias /myproject/static /django/myproject/static
    <Directory /django/myproject/static>
            Order deny,allow
            allow from all
    </Directory>
</VirtualHost>

django.wsgi:

import sys
import os
import django.core.handlers.wsgi

sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'

application = django.core.handlers.wsgi.WSGIHandler()

sys.path.insert(0, '/django/myproject/')
sys.path.insert(0, '/django/myproject/')

from django.core.handlers.wsgi import WSGIHandler

application = WSGIHandler()

Please note I have tried to remove or rename any identifying information from these files for security reasons, so if there is an obvious syntax error etc. it is probably due to this editing. The original versions of these files are the same accept for the name changes and worked well under Django 1.3

Bouke
  • 11,768
  • 7
  • 68
  • 102
Finglish
  • 9,692
  • 14
  • 70
  • 114
  • 1
    Set `DEBUG=True` in `settings.py`. Does that help? – jathanism Jul 24 '12 at 14:11
  • There may be some backward incompatibilities. Set `DEBUG=True`, it may help to identify error source. – machaku Jul 24 '12 at 14:23
  • Sorry, I forgot to mention that I already have DEBUG=True set in my settings. I also tried running a few command through the "django-admin.py shell" to check I could access django and connect to the db – Finglish Jul 24 '12 at 14:30
  • 1
    have you checked both `/home/www/www.mysite.com/logs/error.log` and `/var/log/apache2/error.log` – scytale Jul 24 '12 at 15:03
  • Good point! the the site error log has an error to do with the csrf middleware: ImproperlyConfigured: Middleware module "django.middleware.csrf" does not define a "CsrfResponseMiddleware" class – Finglish Jul 24 '12 at 15:19
  • 1
    OK all working now, as of 1.4 CsrfResponseMiddleware has been removed – Finglish Jul 24 '12 at 16:39

1 Answers1

0

django 1.4 have a wsgi.py file configuratiom included:

See the documentation: https://docs.djangoproject.com/en/1.4/howto/deployment/wsgi/#the-application-object

  • 1
    That's true for projects that were created with the 'django-admin.py startproject' command. This project was created with Django 1.3, and so wouldn't have a wsgi.py file. – Chris Lawlor Sep 28 '12 at 19:52