I’ll just leave this here.

Download these files: (choose the appropriate version for your processor, etc.)

If you’d like to install pip, which is a popular package manager for Python that you may be asked to use to install many different kinds of things, also download these files:

Paths listed are the default paths when I installed these items. If you install a different version or to a different location, it’s up to you to modify the instructions accordingly.

If you’d like to work in an IDE, here are a few to choose from. I have no recommendations, sorry. If you just want a text editor for now, I like SciTE.

  • Install SlikSVN
  • Install ActivePython 2.7
  • Intall MySQL
Close all command prompts, then ensure the following directories are in the system path:
  • C:\Python27\
  • C:\Python27\Scripts
  • C:\Python27\Lib\site-packages\django\bin
  • C:\Program Files\MySQL\MySQL Server 5.5\bin
  • C:\Program Files\SlikSvn\bin

You can configure your path environment variable in Windows by going to the System control panel (Properties on Computer), Advanced, Environment Variables. Path is in the bottom pane, you’ll have to scroll down. Paths are separated by semicolons. It may be useful to copy/paste the string into a text editor to edit/verify.

Open a command prompt and type:

  • cd C:\Python27\Lib\site-packages
  • svn co http://code.djangoproject.com/svn/django/trunk/django

Wait a little while for svn to download Django.

Optional steps for pip installation:

CD to the location where you saved ez_setup.py and type:

  • ez_setup.py -U setuptools

You can delete ez_setup.py after this completes. Next, CD to the location where you extracted pip and type:

  • setup.py install

First steps

CD to the location where you’d like to store your Django project and type:

  • django-admin startproject newproject

This will create a subdirectory for you (called ‘newproject’), you do not need to create a directory to execute it in. Let’s set up a MySQL database:

  • mysql -u root -p
  • mysql> CREATE DATABASE newproject;
  • mysql> exit

MySQL should prompt you for a password after the first command. Now, we’ll need to configure the Django project to use the MySQL database we created. Edit the file settings.py in newproject\newproject. Lines 14-19 contain the database configuration. Set engine to django.db.backends.mysql, name to newproject, user to root, and password to the MySQL root password. Save the file.

Back at the command prompt, verify that things are working by testing with these two commands in your project directory:

  • manage.py syncdb
  • manage.py runserver

The syncdb command may prompt you to configure some settings for Django administration. Runserver will run and stay running on your command prompt; press Ctrl+C to exit it. If there are no errors you will be able to access your Django webserver at http://127.0.0.1:8000/. If you’d like to change the port, just add the port number you want after runserver like so:

  • manage.py runserver port

With all of that done, you should be good to move along with the Django tutorial.

 

Post filed under Things that should be easy.

4 Comments

  1. michael says:

    thank you!

  2. Hi Kris,

    Just wanted to take the time and say a big THANK YOU !!! for this tutorial above. I’ve just started programming and was extremely frustrated with not being able to install ANY database on Django and wasting two days in the process. I followed the instructions and it worked like a charm. So, once again, thanks…

    Fabio

  3. Kunal Kumar says:

    Was Helpful. Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>