{{{
from django.contrib.sitemaps import views as sm_views
class PagesSitemap(Sitemap):
changefreq = "monthly"
i18n=True
def __init__(self, language):
self.language = language
def items(self):
return Pages.objects.filter(is_show=True)
sitemaps = {}
for language in settings.LANGUAGES:
sitemaps['pages-%s' % language[0]] = PagesSitemap(language[0])
urlpatterns += [
url(r'^sitemap.xml$', sm_views.index, {'sitemaps': sitemaps}),
url(r'^sitemap-(?P<section>.+)\.xml$', sm_views.sitemap, {'sitemaps':
sitemaps}),
]
}}}
and get error
{{{
NoReverseMatch at /sitemap.xml
Reverse for 'django.contrib.sitemaps.views.sitemap' with arguments '()'
and keyword arguments '{'section': 'pages-en'}' not found. 0 pattern(s)
tried: []
Request Method: GET
Request URL: http://127.0.0.1:8101/sitemap.xml
Django Version: 1.10.2
Exception Type: NoReverseMatch
Exception Value:
Reverse for 'django.contrib.sitemaps.views.sitemap' with arguments '()'
and keyword arguments '{'section': 'pages-en'}' not found. 0 pattern(s)
tried: []
Exception Location: .venv/local/lib/python2.7/site-
packages/django/urls/resolvers.py in _reverse_with_prefix, line 392
Python Executable: .venv/bin/python
Python Version: 2.7.9
}}}
before update to 1.10.x - it's worked well with Django = 1.6.x to 1.9.x
truble only with 1.10.x
--
Ticket URL: <https://code.djangoproject.com/ticket/27307>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => assigned
* needs_better_patch: => 0
* component: contrib.sitemaps => Documentation
* needs_tests: => 0
* owner: nobody => Tim Graham
* needs_docs: => 0
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/27307#comment:1>
* Attachment "27273.diff" added.
* has_patch: 0 => 1
Comment:
Could you confirm that changing your `url()` as done in the attached patch
fixes it?
--
Ticket URL: <https://code.djangoproject.com/ticket/27307#comment:2>
Comment (by Oleksandr Shtalinberg):
Yes, patch fixes it . Thanks!
--
Ticket URL: <https://code.djangoproject.com/ticket/27307#comment:3>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"fe1aee6b98d2a94ecc983463938135d192ef9afc" fe1aee6]:
{{{
#!CommitTicketReference repository=""
revision="fe1aee6b98d2a94ecc983463938135d192ef9afc"
Fixed #27307 -- Added missing url names in sitemaps docs.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27307#comment:4>
Comment (by Tim Graham <timograham@…>):
In [changeset:"3141b79d26ea2075c38b7b1779325f5b8b9c3baf" 3141b79]:
{{{
#!CommitTicketReference repository=""
revision="3141b79d26ea2075c38b7b1779325f5b8b9c3baf"
[1.8.x] Fixed #27307 -- Added missing url names in sitemaps docs.
Backport of fe1aee6b98d2a94ecc983463938135d192ef9afc from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27307#comment:7>
Comment (by Tim Graham <timograham@…>):
In [changeset:"69a2d0c5bff7e67ec00910491a3939982f75c466" 69a2d0c]:
{{{
#!CommitTicketReference repository=""
revision="69a2d0c5bff7e67ec00910491a3939982f75c466"
[1.9.x] Fixed #27307 -- Added missing url names in sitemaps docs.
Backport of fe1aee6b98d2a94ecc983463938135d192ef9afc from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27307#comment:5>
Comment (by Tim Graham <timograham@…>):
In [changeset:"67fd51a54f5c9d702c2e75dd0aa8520aeb0518ab" 67fd51a5]:
{{{
#!CommitTicketReference repository=""
revision="67fd51a54f5c9d702c2e75dd0aa8520aeb0518ab"
[1.10.x] Fixed #27307 -- Added missing url names in sitemaps docs.
Backport of fe1aee6b98d2a94ecc983463938135d192ef9afc from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27307#comment:6>