This is a basic guide to get Django running with WAMP. This tutorial was written with Python 2.7.5 and Django 1.5 in mind but applies for all versions.
You can use the Windows command prompt (cmd) whenever it says to run a command. I suggest using this command prompt alternative.
mod_wsgi module for apache. I suggest getting it from here. Add mod_wsgi.sotoC:\wamp-2-4.64bit\bin\apache\Apache2.4.4\moduleshttpd.conf: LoadModule wsgi_module modules/mod_wsgi-ap24-py27.sopip install virtualenvwww-src alongside your wamp www folder and navigate to it in cmd using this command: cd C:\wamp-2-4.64bit\www-srcvenv using this command: virtualenv venvC:\wamp-2-4.64bit\www-src\venv\Scripts and run the command activate to get your virtualenv running. You will notice (venv) in cmd.pip install Djangopython django-admin.py startproject mysitehttpd.conf and point to your virtualenv: WSGIPythonHome "C:/wamp-2-4.64bit/www-src/venv"httpd.conf:
WSGIScriptAlias /django-project "C:/wamp-2-4.64bit/www-src/django_project/django_project/wsgi.py"
WSGIPythonPath "C:/wamp-2-4.64bit/www-src/django_project/"
<Directory "C:/wamp-2-4.64bit/www-src/django_project/django_project/">
<Files wsgi.py>
Order deny,allow
Require all granted
</Files>
</Directory>
settings.py:
import os
BASE_DIR = os.path.realpath(os.path.dirname(__file__))
settings.py set up static file stuff:
STATIC_ROOT = 'C:/wamp-2-4.64bit/www/static'
STATIC_URL = 'http://localhost/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
httpd.conf:
Alias /static C:/wamp-2-4.64bit/www/static
<Directory "C:/wamp-2-4.64bit/www/static">
Order deny,allow
Allow from all
Require all granted
</Directory>
manage.py is in the base of your django projects directory
django-admin.py should be on your system path. Problems? See this documentation
| Command | Description |
|---|---|
python manage.py collectstatic | Gets all new or edited static files and puts it in the STATIC_ROOT to be served |
python manage.py syncdb | Update the db structure to reflect your models |
python django-admin.py startproject mysite | Start a django project to host your django apps |
python manage.py startapp polls | Start a django app in your django project |
python manage.py changepassword *username* | Change the password of the specified user. (Optionally, you can visit: example.com/path-to-admin/password_change/ if you have the admin enabled) |