1. Create a project
Command: django-admin startproject mysite
mysite
├─ ─ manage.py
└── mysite
├── __init__.py
├── settings.py
##
├── urls.py
└── wsgi.py
1.manage.py A command line tool for interacting with Django, such as later generating a database table structure based on the model for development The servers used all use this tool. Use python manage.py in the same level directory of manage.py to see the list of commands that can be used
2.mysite: This is the package name of the project.
3.__init__.py: Indicates that mysite is a package.
4.setting.py: Django configuration file, including project app configuration, database configuration, language configuration, etc.
5.urls.py: Django’s dispatcher maps to different views based on different URLs.
6.wsgi.py: WSGI is the web server gateway interface. This file is the entry-point that makes the project conform to this protocol.
2. Create app
Command: python manage.py startapp users
learn/
├── __init__.py
├──admin.py
##├── models.py
├── tests.py
└── views.py
1.learn: The root directory of the app
2.admin.py: Django comes with a management interface , this file can register the model and manage it in the interface
3.__init__.py: Indicates that polls is also a package
4.migrations: Used to initialize the database, after executing python manage.py makemigrations A file will be automatically generated here (version 1.7 or above)
5.__init__.py: Indicates that migrations is also a package
6.models.py: Define the model class in this file
7.tests.py: Write test code
8.views.py: View, when Django maps the URL in urls.py, find the corresponding one in views.py Approach
The above is the detailed content of djiango directory files. For more information, please follow other related articles on the PHP Chinese website!