Practical drills of "Python efficient development practices"-application Building 2 and python efficient development practices
To develop practical applications that conform to the MVC Architecture in the project, you need to create a Django application in the project. Each Django project can contain multiple Django applications. The syntax for creating an application is:
# Python manage. pystartapp Application name
Manage. py is a command line tool generated in the project directory when a project is created. startapp is a command keyword, for example:
#cd djangosite#python manage.py startapp
After the command is complete, the following directory and file structure will be created in the project directory:
App/
_ Init _. py
Admin. py
Apps. py
Migrations/
_ Init _. py
Models. py
Tests. py
Views. py
The file function is parsed as follows:
- _ Init _. py: NO content exists. The existence of this file makes the app a Python package.
- Admin. py: manages the site model declaration file, which is empty by default.
- Apps. py: application information definition file. The AppConfig class is generated, which is used to define Meta data such as the application name.
- Migrations package: used to define the reference migration function.
- Models. py: file used to add data classes at the model layer.
- Tests. py: test the code file.
- Views. py: defines the URL response function.
All the above files have no actual content at the time of application creation, and developers need to write code to complete their functions.
Interested readers can look at the structure of this book "efficient Python development practices"