May 14, 2021 Django
In this chapter we'll show you how to create a project using Django.
Use django-admin.py to create a project named :
django-admin startproject xxx
Once created, we can look at the catalog structure of the next project:
[root@solar ~]# cd HelloWorld/ [root@solar HelloWorld]# tree . manage.py 管理器 |--*** | |-- __init__.py 包 | |-- settings.py 设置文件 | |-- urls.py 路由 | `-- wsgi.py 部署
Catalog description:
Creating an app module automatically generates an app folder that includes several files:
python manage.py startapp app
Description of each directory:
Find the contents of the package in the setting.py and register INSTALLED_APPS app module in the table:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'app',
Enter the command under the package to start the project:
python manage.py runserver
Enter your server's ip and port number in the browser, and if you start normally, you'll get the following interface, which means that the project creation is complete: