Skip to content

Wolfshead Software Blog

Some Random Programming Thoughts

Archive

Tag: Django

Attempt number two.

1. Install Python 2.5.4 into C:\Python25.

2. Copy mod_wsgi.so to the right folder (make sure you get the py2.5 version).

3. Add the line to the httpd.conf file (found in C:\Apache2\conf).

4. Copy the django folder from the svn downloaded copy into C:\Python25\Lib\site-packages make sure that both the Python folder (C:\Python25) the bin folder of the django folder you’ve just added are on the system path.

5. Test the installation as before (now proceed as previously).

6. Configure Apache to use the mod_wsgi module as in the “How to use django with Apache and mod_wsgi” section of the django documentation.

7. Copy the HolyFamily files to C:\djangoisms and point the mod_wsgi setting at the django.wsgi file there.

8. Copy the media files across into C:\Apache2\htdocs\.

9. Make sure the admin media alias in httpd.conf points to the right place (I need to double check this step).

10. Change the django.wsgi file in HolyFamily to point to the correct places.

11. Install the file MySQL-python-1.2.2.win32-py2.5.exe (the backend linking Python to our already installed MySQL database).

12. Create the Django Database and User for the installation.

13. Run the sql file which you have dumped from the development database to create the tables and entries.

14. Make sure settings.py points to the correct paths.

15. Install tagging.

16. We also need to add to the httpd.conf file the following to allow Apache to serve scripts from the folder which contains django.wsgi (this is the same folder which holds the site).

<Directory "C:/Path/To/Parent/Folder/Of/django.wsgi>
Order deny,allow
Allow from all
</Directory>

17. Enjoy

The Holy Family site is now ready to be deployed, as I have not previously deployed a Django site, it seems appropriate to do a dry run first, so I shall document the steps necessary to install it on my windows laptop here. We already have a working Apache and PHP combination on both so we will start by installing Python, then mod_wsgi, and proceed to the django install.

1. Python, the latest version for which a windows binary of mod_wsgi exists is 2.6, so download 2.6.2 and install it to C:\Python26.

2. Copy the mod_wsgi.so file to the C:\Apache2\modules\ folder and rename it to mod_wsgi.so.

3. Add the line LoadModule wsgi_module modules/mod_wsgi.so to the httpd.conf.

4. Get a reasonably up to date version of django trunk (use svn and then copy to the machine).

5. Copy the django folder from this install into the C:\Python26\Lib\site-packages folder and add the bin folder therein to the system PATH.

6. Test the installation by starting python, calling import django and then django.VERSION

7. Configure Apache to use the mod_wsgi module as in the “How to use django with Apache and mod_wsgi” section of the django documentation.

8. Copy the HolyFamily files to C:\djangoisms and point the mod_wsgi setting at the django.wsgi file there.

9. Copy the media files across.

10. Make sure the admin media alias in httpd.conf points to the right place.

11. Change the django.wsgi file in HolyFamily to point to the correct places. Suddenly discover that the mysql backend for windows does not support python 2.6 and have to start all over again from scratch with 2.5.

Joy of joys!!!

As usual I spoke too soon, when I claimed that upgrading to use django-tagging was as easy as. There appears to be a problem with django-tagging if the model which a TagField is being attached to has a Primary Key which is text based. It has taken me a good 24 hours of head scratching to pin it down to this. This creates an error of the form:

invalid literal for int() with base 10: slug-name

when trying to save an object with a tag. Where slug-name refers to the slug of the object name. Basically to cure this requires removing the:

primary_key=true

attribute from the model, flushing the database and re-syncing it with the model. This creates a new auto-incremented primary key field, which needs to be taken into account when reloading the data into the database. That’s all that is required (fingers crossed) to stop the error message from occurring.

Upgraded existing models to use the django-tagging application. Easy as!