This is the fourth post in a dummies guide to getting stared with Python, Django, & MySQL on Windows 7.
- Part 1: getting started
- Part 2: virtual environments
- Part 3: making iPython recognize virtual environments
- Part 4: installing Django (you are here)
- Part 5: installing MySQL
These directions will simply make sure you can get up and running.
- Open a command window.
- Go to (or create) the virtual environment you’ll be using for your django project. For this example, I created a virtualenv called django-tutorial:
virtualenv django-tutorial --no-site-packages
- Install django:
pip install django
- Start an interactive interpreter by typing
iPython, if you’ve made it virtual environment-aware).
- Test the install by importing the django module and checking its version: https://gist.github.com/1177372
- Create a new directory to hold your Django projects and code. Change to it.
- Think of a name for your first Django project and create it by running the following command:
python -m django-admin startproject [projectname].
If that doesn’t work, try
python -m django-admin startproject [projectname] (thanks JukkaN!)
Important: most Django docs show
django-admin.py startproject [projectname]to start a new project, which can cause import errors and other trouble for Windows users. See this stackoverflow thread for details.
- You should now see the project’s folder in your Django directory:
- Change into the new project folder.
- Test the new project by typing
python manage.py. Manage.py is Django’s command line utility; you should see a list of its available subcommands.
- A further test is to start up Django’s development server:
python manage.py runserver. You should see something like this:
If you’ve made it this far, you’ve successfully installed Django and created your first project.
Next up is Part 5: Installing MySQL.