django routing rules

 

  • The directory structure of the project

 The first outer layer of ysitethe directory has nothing to do with Django, but the container of your project, which could be renamed.

 

 

Django settings.py where # is the total profile that steward project 
# urls.py, is the first stage of the route of the project, which is the root of the route, which is the root of all routes for all applications in the project, any of request (all requests sent to the service ip + port) will go through its first check, a routes are denied, then
# of course there will be routed through the next level, but directly returned.
###############################################
# topmost the firstsite is a directory, not a python package;
#firstsite directory of firstsite is the overall configuration of the project related to application management app, is the set of profiles of a project is a python package, not a common directory;
#firstsite directory of firstapp an app project is a python package, not a common directory; this app can have multiple applications. app storage location can be anywhere, but usually put them in the manage.pydirectory of the script at the same level, so easy to import the file.
#firstsite directory there is a project management tool manage.py
##################################### ###########
# enter firstsite project root directory, make sure the manage.pyfile is in the same level, enter the following command:
Python manage.py startappmyapp
graphical buttons Pycharm, no app can be created, it is necessary below the terminal input commands: Python manage.py startApp polls
# 这样就生成了myapp这个应用
#
Terminal

# This can also create polls applications.
 

 

  • Root routing file:
# Root route, i.e. a first stage routing, url URL of the "protocol name + host or IP + port", is followed immediately by a route 
firstsite / urls.py
addition admin routing outside, as far as possible to each app design your own independent secondary routes.

 

Guess you like

Origin www.cnblogs.com/igoodful/p/11480173.html