' blogg' is not a registered namespace,求助
打开/blogg/index页面,显示NoReverseMatch at /blogg/index/' blogg' is not a registered namespace 下面是代码 这是应用下的URL配置 from django.urls import path from . import views app_name = 'blogg' urlpatterns = [ path('index/', views.index), path('article/<int:article_id>/', views.article_page, name='article_page'), ]
这是根url下的配置
from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), path('blogg/', include('blogg.urls', namespace='blogg')), path('blog2/', include('blog2.urls')), ]
这是index.html文件
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <h1> <a href="">新文章</a> </h1> {% for article in articles %} <a href="{% url ' blogg:atricle_page ' article.id %}">{{ article.title }}</a> <br/> {% endfor %} </body> </html>