Home > Backend Development > Python Tutorial > How to create a Django program

How to create a Django program

伊谢尔伦
Release: 2017-06-28 12:20:24
Original
1436 people have browsed it

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
Copy after login

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,其实他就是对你大的工程的一个分类      
'''
Copy after login

Create App

python manage.py startapp app01
Copy after login

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
Copy after login

Create super user

python manage.py createsuperuser
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template