Django

Code

Ticket #11358 (new)

Opened 8 months ago

Last modified 1 week ago

Flatpage sitemap shows all pages, even private pages

Reported by: dburke Assigned to: nobody
Milestone: Component: Contrib apps
Version: 1.0 Keywords:
Cc: Triage Stage: Accepted
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

I tried searching trac for this issue, but wasn't able to turn up anything relevant.

Flatpages allow you to make a page visible only to logged in users, but the flatpage sitemap reveals the url. Would it be possible to add a .filter(registration_required=False) to the queryset that populates the flatpage sitemap?

in django.contrib.sitemaps:

class FlatPageSitemap(Sitemap):
    def items(self):
        from django.contrib.sites.models import Site
        current_site = Site.objects.get_current()
        return current_site.flatpage_set.filter(registration_required=False)

Attachments

Change History

08/18/09 01:07:15 changed by kmpm

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

You almost answered it yourself. I don't know if its worth doing a modification to sitemaps just for this. Save your class but with another name like "FlatPagePublicSitemap?" in a file called "sitemaps.py" for example. Include ( from sitemaps include FlatPagePublicSitemap? ) and use that class in your urls.py instead of the ordinary FlagPageSitemap?.

Is that a good enough solution for you?

08/18/09 21:22:33 changed by dburke

Yeah, this solution is fine. Should be made a little more explicit in the Documentation? Or should we hope that google helps direct people seeking this solution here?

02/02/10 06:55:36 changed by russellm

  • stage changed from Unreviewed to Accepted.

A sitemap exists for the benefit of public spiders and crawlers, so there isn't much point having a sitemap that includes private pages.


Add/Change #11358 (Flatpage sitemap shows all pages, even private pages)




Change Properties
Action