解决 Set the app_name attribute in the included module..... url反向解析

在使用Django 2.2时遇到'ImproperlyConfigured'错误,提示需设置'app_name'。本文档介绍了问题背景,错误原因及简单的解决方案,即在项目urls.py的include中添加应用名,帮助Python Django初学者理解并解决问题。
摘要由CSDN通过智能技术生成

解决 Set the app_name attribute in the included module, or pass a 2-tuple containing the list of patterns and app_name instead.

在学习url反向解析时,遇到的这个问题
环境:python3.8+Django2.2
项目名:test4
应用名:booktest

项目的urls.py

from django.contrib import admin
from django.urls import path
from django.conf.urls import url, include

urlpatterns = [
    path('admin/', admin.site.urls),
    url(r'^', include('booktest.urls', namespace='booktest'))
]

应用的urls.py

from django.conf.urls import url
from booktest import views

urlpatterns = [
    url(r'^index$', views.index, name='index'),
    url(r'^url_reverse$', views.url_reverse),
]

templates文件夹下的与该应用相关的html文件

&
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值