django2.1.7 urls怎么写

485次阅读
没有评论

django2.1.7

基于Django2.1.7配置URLS
1.在项目文件中直接配置URL的相关代码如下:

from django.contrib import admin
from django.urls import path
from BookManageSystem import views
urlpatterns = [
  path('admin/',admin.site.urls),
  path('index',views.index),
]

2.在应用中创建urls.py,再到项目的URL文件中配置
在应用中的url文件进行URL配置代码如下

from django.urls import re_path
from BookManageSystem import views
urlpatterns = [
    re_path(r'^index$', views.index),
]

在项目的url文件中的配置代码如下:

from django.contrib import admin
from django.urls import re_path, include, path
urlpatterns = [
    path('^admin/',admin.site.urls),
    re_path(r'^', include('BookManageSystem.urls')),
    ]
神龙|纯净稳定代理IP免费测试>>>>>>>>天启|企业级代理IP免费测试>>>>>>>>IPIPGO|全球住宅代理IP免费测试

相关文章:

版权声明:wuyou2019-10-11发表,共计645字。
新手QQ群:570568346,欢迎进群讨论 Python51学习
评论(没有评论)