Opened 13 years ago
Closed 11 years ago
#16829 closed New feature (fixed)
sitemap for static views
Reported by: | madisv | Owned by: | Zbigniew Siciarz |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | views sitemap |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
People also use static views which are not FlatPages. So it's a problem creating a sitemap for such urls.
This is not hard to do if you know how so should this code maybe also be in django or might we just document this so people would know how to do this.
Problem explained also:
http://stackoverflow.com/questions/4836188/django-sitemaps-and-normal-views
Solution by Matt Austin:
from django.core.urlresolvers import reverse
from django.contrib.sitemaps import Sitemap
class ViewSitemap(Sitemap): """Reverse static views for XML sitemap.""" def items(self): # Return list of url names for views to include in sitemap return ['homepage', 'news_article_list', 'contact_page'] def location(self, item): return reverse(item) sitemaps = {'views': ViewSitemap, 'news_articles': ArticleSitemap}
Change History (9)
comment:1 by , 13 years ago
Component: | contrib.sitemaps → Documentation |
---|---|
Has patch: | unset |
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 12 years ago
This is a real issue, and i agree with carljm, if you suggest me a place for adding the documentation i can do that.
comment:4 by , 11 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Version: | 1.3 → master |
comment:6 by , 11 years ago
Has patch: | set |
---|
comment:9 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
I don't think this code needs to be in Django, but the sitemaps documentation could benefit from an example like this showing how to add static views to a sitemap.