Home > Python, Web > Setup Django

Setup Django

OK, here’s the simplest way/setting for Django. I am using mac, but it should be similar for other linux.

First. Installing an official release.

  1. Download the latest release from download page.
  2. Untar the downloaded file (e.g. tar xzvf Django-X.Y.tar.gz, where X.Y is the version number of the latest release).
  3. Change into the directory created in step 2 (e.g. cd Django-X.Y).
  4. If you’re using Linux, Mac OS X or some other flavor of Unix, enter the command sudo python setup.py install at the shell prompt.

After install it, run python in the command line, and check:

import django
print django.get_version()

Second,  is to Configure your database and create your first app.

From the command line, cd into a directory where you’d like to store your code, then run the following command:

django-admin.py startproject mysite
Since you install it through command line, ‘django-admin.py’ should be in your system path. If you can not find it, try to find it in site-packages/django/bin, where site-packages is a directory within your Python installation. Consider symlinking to django-admin.py from some place on your path, such as /usr/local/bin.
The above command will create your first site like this:

Now run the server by doing:

python manage.py runserver.

You will see somthing like this in your terminal:

Validating models...
0 errors found.Django version 1.4, using settings 'mysite.settings'
Development server is running at
Quit the server with CONTROL-C.
 goto,  cool, it works.  Please also note that MAC actually comes with a embedded Apache Server, you may like to check in details here.
Now you needs to configure you database. Edit mysite/settings.py. To make it as simple as possible, use sqlite3 ( it goes with python, so you don’t have to install additional packages) Change the ENGINE from ‘django.db.backends.‘ to ‘django.db.backends.sqlite3‘.
OK, you are now ready for creating your own models 🙂
Categories: Python, Web Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: