1.创建App命令
1.1 cd 目录 python manage.py startapp app01
创建完成后
1.2
在settings文件中,找到INSTALLED_APPS=[] 中,添加 ‘ app01.apps.App01Config ’
如下所示:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'AppLogin.apps.ApploginConfig',
'TestRoute.apps.TestrouteConfig',
]
1.3 在主App 的urls中,添加引用 include 模块(事前在App01中增加urls.py 文件)
from django.conf.urls import url,include
urlpatterns 中,进行如下操作
urlpatterns=[
url(r'^App01/',include("App01.urls"))
]
1.4 在对应的App中,增加urls.py 文件,如本文中的App01.urls
里面的配置文件如下:
from django.conf.urls import url
from TestRoute import views
urlpatterns = [
url(r'^blogs/pages/(?P<num>[0-9]{2})',views.blogs)
]
------------恢复内容结束------------