Home >Backend Development >Python Tutorial >How to create a Django program
CreateDjangoProgram
Terminal command: django-admin startproject sitename
When the IDE creates a Django program, it essentially automatically executes the above commands
The above sitename is the project name defined by yourself!
Other commonly used commands:
python manage.py runserver 0.0.0.0:port python manage.py startapp appname python manage.py syncdb python manage.py makemigrations python manage.py migrate python manage.py createsuperuser
settings.py stores configuration files
urls.py stores routingsystem (mapping)
wsgi.py allows you to configure: wsgi has multiple types, uwsgi and wsgi. Which wsgi do you use to run Django? Generally, you don’t need to change it. You can only change it when you use it
manage .py is the startup management program of Django
The above configuration files, if you are a beginner, do not modify it after creating the project, because it involves many configuration files that need to be modified
Project and App concepts
What we are currently creating is Project. There can be many apps under Project. What is the principle?
The Project we created is a large project with many functions: (A Project has multiple Apps. In fact, it is a classification of your large project)
''' Project --web (前台功能) --administrator (后台管理功能) 一个Project有多个app,其实他就是对你大的工程的一个分类 '''
Create App
python manage.py startapp app01
If we are creating an App, we can understand that the App is an App program in the mobile phone and they are completely independent. The advantage is to reduce the coupling between them. Don’t let them interact unless absolutely necessary. Build relationships!
The admin in the app provides a background management platform, and test is used for testing!
Admin background management:
Synchronize database
python manage.py syncdb #注意:Django 1.7.1及以上的版本需要用以下命令python manage.py makemigrations python manage.py migrate
Create super user
python manage.py createsuperuser
Enter the user name and password you want to set, then start Django, and then enter RUL/admin is enough: http://127.0.0.1:8000/admin/
The above is the detailed content of How to create a Django program. For more information, please follow other related articles on the PHP Chinese website!