My Django project setup

This is a continuation of the series of posts on my workflow with Django. I am writing as a means of documenting my work, but feel free to follow it you find it helpful.

This is loosely based on the Django tutorial from here. This tutorial uses the 1.5 version of Django.

Project setup

Let’s set up a Django project!

Creating a project

To create a project, use the following command startproject myproject.

This will create a starter project with the following structure:


Database settings

Now, if you change to the directory that contains the file, you can change your projects settings. Here you can specify the database engine you will be using (SQLite, PostgreSQL or MySQL) and enter the database credentials (if applicable).

The following is an excerpt of

    "default": {
        "ENGINE": "django.db.backends.postgresql_psycopg2", # Add "postgresql_psycopg2", "mysql", "sqlite3" or "oracle".
        "NAME": "MY_DATABASE_NAME",                      # Or path to database file if using sqlite3.
        # The following settings are not used with sqlite3:
        "HOST": "",                      # Empty for localhost through domain sockets or "" for localhost through TCP.
        "PORT": "",                      # Set to empty string for default.

I changed the engine to be django.db.backends.postgresql_psycopg2 as I will be using PostgreSQL. I already created the database so I added the database name, user, and password also.

If you are going to be using any other database or need more information, refer to the Django documentation.

Sync database

To sync the database to create the database tables, use this command python syncdb.

This will create the database tables for the installed apps that you have enabled in your file.

Get to work!

The project is now set up. You can continue now by creating an app.

more ...

About Giselle Zeno
I'm a Computer Science PhD student at Purdue and an avid coder. more