Opened 5 years ago

Closed 4 years ago

#16829 closed New feature (fixed)

sitemap for static views

Reported by: madisv Owned by: Zbigniew Siciarz
Component: Documentation Version: master
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 Changed 5 years ago by Carl Meyer

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 Changed 5 years ago by Jacob

milestone: 1.4

Milestone 1.4 deleted

comment:3 Changed 4 years ago by Camilo Nova

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 Changed 4 years ago by Zbigniew Siciarz

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

comment:5 Changed 4 years ago by Zbigniew Siciarz

comment:6 Changed 4 years ago by Zbigniew Siciarz

Has patch: set

comment:7 Changed 4 years ago by pyriku

Triage Stage: AcceptedReady for checkin

Looks OK to me

comment:8 Changed 4 years ago by Zbigniew Siciarz <antyqjon@…>

In d77082b43877b4df0f29fa977b73b7b4feab84d4:

Added example of using sitemaps with static views.

References #16829.

comment:9 Changed 4 years ago by Tim Graham

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