Practical drills of "Python efficient development practices"-application Building 2 and python efficient development practices

Source: Internet
Author: User

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"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.