Introduction to the Django Web framework
The Django project is a python[1] custom framework that originated in an online news web site and was released in 2005 as an Open-source form. The core components of the Django framework are:
The object-relational mapping used to create the model is the perfect management interface designed for end users the first class URL design designer-friendly template language caching system. Django conforms to MTV architecture
Django Installation
There are two ways to install Django, specifically refer to the official website (https://www.djangoproject.com/download/), which uses the second method, option 2. Get the latest development version, specifically as follows:
[Dw_mon@tddba ~]$ git clone https://github.com/django/django.git
[dw_mon@tddba install]$ cd Django
[Dw_ MON@TDDBA django]$ python setup.py install
Once the installation is successful, you can use the Django Administration tool django-admin.py
Django Projects and Applications
Create a Django project with the following command:
[Dw_mon@tddba project]$ django-admin.py startproject eshop
The above command creates a eshop folder (that is, a project) under the current directory that contains the basic configuration files needed to run the Django project:
[Dw_mon@tddba eshop]$ ls
__init__.py settings.py urls.py wsgi.py
Next, we will create an application order under this project:
[Dw_mon@tddba eshop]$ python manage.py startapp order
The above command creates an order directory under the current directory, which has the following files:
[Dw_mon@tddba eshop]$ CD order
[dw_mon@tddba products]$ ls
admin.py __init__.py tests.py views.py
Providing the location of an application in a project is simply a custom established for new Django developers and is not required.
To enable Django to recognize the existence of a new application, you also need to add an entry to the Installed_apps in the settings.py file:
Installed_apps = (
' django.contrib.admin ',
' Django.contrib.auth ', '
django.contrib.contenttypes ',
' django.contrib.sessions ',
' django.contrib.messages ', '
django.contrib.staticfiles
', ' Order ',
)