django-admin startproject mysite
This will create a Django project named
Do not name projects with the names of built-in
modules to avoid conflicts. Consider the structure of the project:
mysite/ manage.py mysite/ __init__.py settings.py urls.py wsgi.py
It includes the following files:
manage.pyis a command line utility used to interact with the project. It is a thin shell for
django-admin.py.You cannot edit this file.
mysite/is a project directory consisting of the following files:
__init__.py– an empty file that tells Python to treat
mysiteas a Python module.
settings.py– enables project settings with defaults.
urls.py– where URL patterns are stored. Each URL defined here is used for presentation.
wsgi.py– configuration to run the project as a Web Server Gateway Interface (WSGI) application
settings.py 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 manage.py 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”.