Django Blog #2: Creating a Project

by Alex
Django Blog #2: Creating a Project
Django has a command that allows you to create a basic file structure for your project. Write the following at the command line:

django-admin startproject mysite

This will create a Django project named mysite.

Do not name projects with the names of built-in Python or Django

modules to avoid conflicts. Consider the structure of the project:


It includes the following files:

  • is a command line utility used to interact with the project. It is a thin shell for You cannot edit this file.
  • mysite/ is a project directory consisting of the following files:
    • – an empty file that tells Python to treat mysite as a Python module.
    • – enables project settings with defaults.
    • – where URL patterns are stored. Each URL defined here is used for presentation.
    • – configuration to run the project as a Web Server Gateway Interface (WSGI) application

The generated file contains the project settings, including the basic configuration for using the SQLite 3 database and the INSTALLED_APPS list, with the main Django applications. These are added to the project by default. These will be covered later in the “Project Settings” article. To complete the installation of the project, you need to create the database tables you need for the applications listed in INSTALLED_APPS. Open the command line and use the following commands:

cd mysite 
python migrate

The following output will appear:

Applying contenttypes.0001_initial... OK 
Applying auth.0001_initial... OK 
Applying admin.0001_initial... OK 
Applying admin.0002_logentry_remove_auto_add... OK 
Applying contenttypes.0002_remove_content_type_name... OK 
Applying auth.0002_alter_permission_name_max_length... OK 
Applying auth.0003_alter_user_email_max_length... OK 
Applying auth.0004_alter_user_username_opts... OK 
Applying auth.0005_alter_user_last_login_null... OK 
Applying auth.0006_require_contenttypes_0002... OK 
Applying auth.0007_alter_validators_add_error_messages... OK 
Applying auth.0008_alter_user_username_max_length... OK 
Applying auth.0009_alter_user_last_name_max_length... OK 
Applying sessions.0001_initial... OK

These lines denote Django database migrations. They create tables for the underlying applications in the database. The migrate command is discussed in the article “Creating and Using Migrations”.

Related Posts