Opened 8 years ago

Closed 6 years ago

Last modified 5 years ago

#10909 closed (fixed)

Allow use of the Sitemaps Framework without requiring the sites contrib application

Reported by: QingFeng Owned by: nobody
Component: Contrib apps Version: master
Severity: Keywords:
Cc: qingfeng@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Django Sitemaps Framework does not allow the use of the Domain Settings Site

In settings.py add a variable DOMAIN

DOMAIN = 'www.example.com'

example:
location of the place, do not rely on the domain name Site Settings

class KhufuSitemap(Sitemap):
    changefreq = "never"
    priority = 0.5

    def items(self):
        return [obj,obj,obj]

    def location(self,obj):
        return "/v/%s/" % obj["kid"]

    def lastmod(self, obj):
        return datetime.strptime(obj["savedate"],'%Y-%m-%d')

Attachments (4)

sitemaps.patch (1.2 KB) - added by QingFeng 8 years ago.
sitemaps2.patch (1.9 KB) - added by QingFeng 8 years ago.
Google ping modify the domain settings
10909.diff (1.9 KB) - added by Chris Beaven 7 years ago.
sitemaps_custom_domain_docs_tests.diff (7.5 KB) - added by daniellindsley 7 years ago.
And now with a docstring (docs+tests).

Download all attachments as: .zip

Change History (15)

Changed 8 years ago by QingFeng

Attachment: sitemaps.patch added

comment:1 Changed 8 years ago by Joey Wilhelm

I won't close this myself, as I have no official word in the development of Django... but this appears to be invalid.

DOMAIN is not a setting which is currently set or used anywhere else in Django. Nor does it appear to really be necessary. Django can't account for every setting that you may add to your project.

comment:2 in reply to:  1 Changed 8 years ago by QingFeng

Replying to Tarken:

I won't close this myself, as I have no official word in the development of Django... but this appears to be invalid.

DOMAIN is not a setting which is currently set or used anywhere else in Django. Nor does it appear to really be necessary. Django can't account for every setting that you may add to your project.

:)To do so is to facilitate, as some projects with less than a database, the current code can not output the Sitemap

comment:3 Changed 8 years ago by QingFeng

New Patch:

1. Google ping modify the domain settings

Changed 8 years ago by QingFeng

Attachment: sitemaps2.patch added

Google ping modify the domain settings

comment:4 Changed 7 years ago by Chris Beaven

Keywords: sitemaps removed
Needs documentation: set
Summary: Django Sitemaps Framework does not allow the use of the Domain Settings SiteAllow use of the Sitemaps Framework without requiring the sites contrib application
Triage Stage: UnreviewedAccepted
Version: 1.0SVN

It's a useful idea, but adding a setting isn't the way to go about it. I'm attaching a better version - it just needs docs if someone wants to write them.

Changed 7 years ago by Chris Beaven

Attachment: 10909.diff added

comment:5 Changed 7 years ago by QingFeng

milestone: 1.2

comment:6 Changed 7 years ago by daniellindsley

milestone: 1.21.3
Needs documentation: unset

Added docs & tests (plus SmileyChris' patch).

Changed 7 years ago by daniellindsley

And now with a docstring (docs+tests).

comment:7 Changed 6 years ago by anonymous

Is this a dupe of #10235?

comment:8 Changed 6 years ago by Mark Lavin

This is essentially the same problem as #10235 and #10608 but I would say adding the get_domain to SiteMap is probably better than the other solutions offered which try into RequestSite.

comment:9 Changed 6 years ago by Luke Plant

Resolution: fixed
Status: newclosed

(In [13980]) Fixed #14386, #8960, #10235, #10909, #10608, #13845, #14377 - standardize Site/RequestSite usage in various places.

Many thanks to gabrielhurley for putting most of this together. Also to
bmihelac, arthurk, qingfeng, hvendelbo, petr.pulc@…, Hraban for
reports and some initial patches.

The patch also contains some whitespace/PEP8 fixes.

comment:10 Changed 6 years ago by Luke Plant

(In [13987]) [1.2.X] Fixed #14386, #8960, #10235, #10909, #10608, #13845, #14377 - standardize Site/RequestSite usage in various places.

Many thanks to gabrielhurley for putting most of this together. Also to
bmihelac, arthurk, qingfeng, hvendelbo, petr.pulc@…, Hraban for
reports and some initial patches.

The patch also contains some whitespace/PEP8 fixes.

Backport of [13980] from trunk. Some items could be considered features
(i.e. supporting RequestSite in various contrib apps), others are definite
bugs, but it was much more robust to backport all these tightly related
changes together.

comment:11 Changed 5 years ago by Jacob

milestone: 1.3

Milestone 1.3 deleted

Note: See TracTickets for help on using tickets.
Back to Top