6

I am running the development version of Django and it appears that the filebrowser app is not compatible with trunk because of changes made to CSRF. How do I downgrade to the official release (1.1)?

I am working on a shared host and the way that I am curently running Django is as follows:

~/local/lib/python2.6/site-packages/ contains /django/ as well as several other folders (one for each app).

~/local/lib/python2.6/site-packages/ is on the python path.

Within /site-packages/ there is also a symlink to /projectname/ that contains the project files (manage.py, settings.py, etc.).

I am using FastCGI and therefore in /public_html/ I have a dispatch.fcgi that is used to call django.core.servers.fastcgi.runfastcgi. A .htaccess file is used to redirect all requests to dispatch.fcgi so that Django can handle them.

I tried removing (moving out of the python path) /django/ and then downloading the release version of Django and putting it where the previous /django/ folder was. This produced the following error:

No module named CSRF.

I downloaded middleware/csrf.py from /trunk/ which cleared up the first error but then produced other errors.

How should I go about downgrading to 1.1? Starting from scratch isn't out of the question but I'd obviously rather avoid this if possible.

Peter Horne
  • 6,472
  • 7
  • 39
  • 50

3 Answers3

8

Look in your /site-packages/ directory for Django-1.other_stuff.egg-info files and delete any you find, then try again (with the code for 1.1 still in the site-packages/django/ directory. If this doesn't work, just re-run the Django installer from the latest release tarball (python setup.py install) and you should be good.

Alternatively, if you have pip installed you can probably just do pip install -U Django==1.1.1 in the terminal.

Note the capital D in Django in those egg-info files and the pip command.

John Debs
  • 3,714
  • 2
  • 25
  • 35
  • Using python setup.py install is out of the question unfortunately as I do not have sufficient rights to edit anything within /usr/ (I can only modify /home/username/ – Peter Horne Nov 12 '09 at 00:14
  • I forgot to add: There were no .egg files either. – Peter Horne Nov 12 '09 at 00:16
  • Which version of Django did you create the project with? If you created the project with trunk, start over using 1.1 assuming you haven't gotten too far. There are changes to the default settings.py (in particular, loading those new CSRF middleware) that won't work with older version of Django. On a separate note, you should consider using virtualenvs with your host (http://pypi.python.org/pypi/virtualenv) to isolate and better control your environment. – John Debs Nov 12 '09 at 01:59
  • 1
    **First**: I just did a `pip install -u django=1.1.3` without the capital D and it worked fine so while it may be required elsewhere it wasn't in `pip`'s case. --- **Second**: I'd _accidentally_ upgraded Django to 1.5.1 because `pip` saw it as a dependency to something else I was installing. However an application on this host hasn't yet been migrated from 1.1 so it broke as expected. A quick `pip install -U django=1.1.3` and it's back in working order. **I am now impressed with `pip`**. – Lake May 07 '13 at 19:55
1

I have managed to successfully downgrade and it is actually an extremely easy process. Hopefully this will help people out who overlook what I did.

The startproject command of django-admin.py in 1.1.1 creates a slightly different settings.py file than the current development release.

startproject in with the current dev release has an extra middleware class - csrf. The startproject command in 1.1.1 creates the same settings.py but with the third class removed. Commenting out or removing this line gets Django working properly.

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware', #additional middleware class
    'django.contrib.auth.middleware.AuthenticationMiddleware',
)
Peter Horne
  • 6,472
  • 7
  • 39
  • 50
1

you can just install django of the version you want in you user space, say in /home/me/lib/

then if you are using mod_wsgi in your mysite.wsgi have a line:

sys.path.insert(0,'/home/me/lib/Django-1.1')

this will insure that django is loaded from your installation, not the server-wide.

you'll also need to adjust your shell environment path variable so that correct django-admin.py is launched or just run directly

python /home/me/lib/Django-1.1/django/bin/django-admin.py ...
Evgeny
  • 10,698
  • 9
  • 60
  • 70
  • This is an excellent "best of both worlds", allowing me to use the latest Django for applications which support it without breaking those which have not yet been updated. – Lake Dec 13 '13 at 09:28