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 Carl Meyer, 13 years ago

Component: contrib.sitemapsDocumentation
Has patch: unset
Triage Stage: UnreviewedAccepted

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.

comment:2 by Jacob, 13 years ago

milestone: 1.4

Milestone 1.4 deleted

comment:3 by Camilo Nova, 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 Zbigniew Siciarz, 11 years ago

Owner: changed from nobody to Zbigniew Siciarz
Status: newassigned
Version: 1.3master

comment:5 by Zbigniew Siciarz, 11 years ago

comment:6 by Zbigniew Siciarz, 11 years ago

Has patch: set

comment:7 by pyriku, 11 years ago

Triage Stage: AcceptedReady for checkin

Looks OK to me

comment:8 by Zbigniew Siciarz <antyqjon@…>, 11 years ago

In d77082b43877b4df0f29fa977b73b7b4feab84d4:

Added example of using sitemaps with static views.

References #16829.

comment:9 by Tim Graham, 11 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.
Back to Top