pythondjangodjango-modelsdjango-sitemaps

NoReverseMatch at /sitemap.xml Django


Django Noob here.

NoReverseMatch at /sitemap.xml Reverse for 'article_detail' not found. 'article_detail' is not a valid view function or pattern name.

See models.py screenshot (code) to understand the error.

I don't know what I should put in place of article_details (see the code for explanation). Your help will appreciable.

Error- NoReverseMatch at /sitemap.xml

Project Structure-

Project Structure-

Code-

Dipesh_Pal Module Code-

settings.py-

INSTALLED_APPS = [
'django.contrib.sitemaps',
'django.contrib.sites',
]
SITE_ID = 1

urls.py- urls.py

home Module Code-

sitemaps.py- sitemaps.py

urls.py- urls.py

models.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.

For your information, I am referring this YouTube video- Click Here

My Github Repo for this App- Click Here


Solution

  • NoReverseMatch at /sitemap.xml Reverse for 'article_detail' not found. 'article_detail' is not a valid view function or pattern name.

    This means that when it went looking for the view article_detail it could not be found. In your urls.py you have the line:

    url(r'^(?P<slug>[w\-]+)/$', views.article_detail, name="article-detail")

    You never included your views.py and this the question is in general formatted pretty poorly, but from what we can see it appears you just never declare that view (even though you reference it in the urls.py)

    EDIT: There is also the possibility that you aren't passing the objects to index in your sitemap when you create the Sitemap, but again.. As the formatting isn't everything we need. We can only speculate.

    So, definitely check that article_detail is working in general. If it is, go to where you are creating the data for your Sitemap object and make sure that you're passing an object with the url.