Deployment¶
Managed to get it running with mod_wsgi and Apache. Well see for yourself
here. Also
you would probably need to build your own settings.py for production
(see below). Here is the approximate howto.
See, whether you have Apache 2 and
mod_wsgiproperly installed and configured. What for Django, I primarily work with Django 1.7c1, which could be installed this way:pip install git+git://github.com/django/django.git@1.7c1
Warning
Later versions of Django are most certainly going to break, as
django-noseuses some deprecated functionality. I’m just hoping they are going to update their code soon.Your Apache config will probably look similar to this:
WSGIPythonPath /home/wswld/Code/menage/core <VirtualHost *:80> ServerAdmin admin@site.com ServerName site.net WSGIScriptAlias / /home/site/menage/core/wsgi.py <Directory /> Allow from all AllowOverride None </Directory> <Directory /home/site/menage/core> <Files wsgi.py> Allow from all </Files> </Directory> Alias /static /home/site/menage/core/static <Directory /home/site/menage/core/static> Order deny,allow Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log LogLevel warn </VirtualHost>Where
/home/site/menage/is the directory you have cloned the git repository to.Now you have to fill out your custom
settings.pyfile and get something similar to this:from settings_universal import * DEBUG = False TEMPLATE_DEBUG = False ALLOWED_HOSTS = ['*'] DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. 'NAME': 'mng', # Or path to database file if using sqlite3. 'USER': 'admin', # Not used with sqlite3. 'PASSWORD': 'passwd', # Not used with sqlite3. 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. 'PORT': '', # Set to empty string for default. Not used with sqlite3. } }
Sure there could be some variations and something may occassionally break. Perhaps you will need to make some alterations, while debugging. What I mean is: there is no one-size-fits-all solution out there, but this workflow is pretty basic and it has been working for me.
Custom Settings¶
Django will use whatever is put to settings.py, which imports all the
defaults from settings_universal.py. Basically you could change nothing
and then all the settings from settings_universal.py are used, or you
could override it, adding your customizations to settings.py.
If you change the settings.py file, a good practice would be to issue:
git update-index --assume-unchanged calc/settings.py
So that no custom settings appear in the repository. If you need to undo the command above, try:
git update-index --no-assume-unchanged calc/settings.py
For the most part settings_universal.py contains default Django
settings now, but I’m going to get rid of some of them and add new stuff there.
Please check the file from time to time. Ideally I want to keep it as a
hassle-free universal development setup with SQLite3.