/sitemap.xml Django 的 NoReverseMatch
NoReverseMatch at /sitemap.xml Django
这里是 Django 菜鸟。
NoReverseMatch at /sitemap.xml Reverse for 'article_detail' not found. 'article_detail' is not a valid view function or pattern name.
查看 models.py 屏幕截图(代码)以了解错误。
我不知道应该用什么来代替 article_details(请参阅代码以获取解释)。 您的帮助将不胜感激。
错误-
项目结构-
代码-
Dipesh_Pal模块代码-
settings.py-
INSTALLED_APPS = [
'django.contrib.sitemaps',
'django.contrib.sites',
]
SITE_ID = 1
urls.py-
home模块代码-
sitemaps.py-
urls.py-
models.py-
The error in line 37. I am not exactly sure what I should put in place
of "article_detail" or I am not sure what exactly wrong in my code.
供您参考,我指的是这个 YouTube 视频- Click Here
我的 Github 这个应用程序的回购 - Click Here
NoReverseMatch at /sitemap.xml Reverse for 'article_detail' not found.
'article_detail' is not a valid view function or pattern name.
这意味着当它去寻找视图时 article_detail
找不到它。在您的 urls.py
中,您有以下行:
url(r'^(?P<slug>[w\-]+)/$', views.article_detail, name="article-detail")
你从来没有包含你的 views.py 并且这个问题的格式通常很糟糕,但从我们可以看到的情况来看,你似乎从未声明过该视图(即使你在 urls.py
)
编辑:也有可能您在创建站点地图时没有将对象传递给站点地图中的索引,但又一次……因为格式并不是我们所需要的一切。我们只能推测。
所以,一定要检查 article_detail
是否正常工作。如果是,请转至为 Sitemap 对象创建数据的位置,并确保传递的对象带有 url.
这里是 Django 菜鸟。
NoReverseMatch at /sitemap.xml Reverse for 'article_detail' not found. 'article_detail' is not a valid view function or pattern name.
查看 models.py 屏幕截图(代码)以了解错误。
我不知道应该用什么来代替 article_details(请参阅代码以获取解释)。 您的帮助将不胜感激。
错误-
项目结构-
代码-
Dipesh_Pal模块代码-
settings.py-
INSTALLED_APPS = [
'django.contrib.sitemaps',
'django.contrib.sites',
]
SITE_ID = 1
urls.py-
home模块代码-
sitemaps.py-
urls.py-
models.py-
The error in line 37. I am not exactly sure what I should put in place of "article_detail" or I am not sure what exactly wrong in my code.
供您参考,我指的是这个 YouTube 视频- Click Here
我的 Github 这个应用程序的回购 - Click Here
NoReverseMatch at /sitemap.xml Reverse for 'article_detail' not found. 'article_detail' is not a valid view function or pattern name.
这意味着当它去寻找视图时 article_detail
找不到它。在您的 urls.py
中,您有以下行:
url(r'^(?P<slug>[w\-]+)/$', views.article_detail, name="article-detail")
你从来没有包含你的 views.py 并且这个问题的格式通常很糟糕,但从我们可以看到的情况来看,你似乎从未声明过该视图(即使你在 urls.py
)
编辑:也有可能您在创建站点地图时没有将对象传递给站点地图中的索引,但又一次……因为格式并不是我们所需要的一切。我们只能推测。
所以,一定要检查 article_detail
是否正常工作。如果是,请转至为 Sitemap 对象创建数据的位置,并确保传递的对象带有 url.