Opened 6 years ago

Closed 5 years ago

#16175 closed New feature (fixed)

Use TemplateResponse in django.contrib.sitemaps

Reported by: Mathieu Pillard Owned by: nobody
Component: contrib.sitemaps Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Like it was done for the admin in #15008 , it would be useful to convert django.contrib.sitemaps views to TemplateResponse, in order to help apps/projects re-use it while adding some stuff in the context.

For instance, the django-news-sitemaps news_sitemap() view is almost a straight copy/paste from django.contrib.sitemaps.views.sitemap(), just adding a couple items in the context (and changing a couple other lines but that's a different issue)

Attached is a very simple patch that does exactly that, passing all current tests.

Attachments (1)

sitemaps-use-templateresponse.diff (2.2 KB) - added by Mathieu Pillard 6 years ago.
Patch (with docs) against [16341]

Download all attachments as: .zip

Change History (7)

comment:1 Changed 6 years ago by Aymeric Augustin

Needs documentation: set
Triage Stage: UnreviewedAccepted

Changed 6 years ago by Mathieu Pillard

Patch (with docs) against [16341]

comment:2 Changed 6 years ago by Aymeric Augustin

Needs documentation: unset

comment:3 Changed 6 years ago by klette

Triage Stage: AcceptedReady for checkin

comment:4 Changed 5 years ago by Jannis Leidel

Needs tests: set
Triage Stage: Ready for checkinAccepted

comment:5 Changed 5 years ago by Mathieu Pillard

What kind of tests would be appropriate ? Just something to check if the response is a TemplateResponse? Something else ?

comment:6 Changed 5 years ago by Jannis Leidel

Resolution: fixed
Status: newclosed

In [16476]:

Fixed #16175 -- Modified the sitemaps views to return TemplateResponse instances for easier customization. Thanks, mat.

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