Opened 4 years ago

Closed 2 years ago

#30923 closed Cleanup/optimization (fixed)

Out of date examples in docs that call render() with a Context instance instead of regular dict

Reported by: Alasdair Nicol Owned by:
Component: Documentation Version: dev
Severity: Normal Keywords: Context render template
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Mariusz Felisiak)

Following #30906, I found a couple more examples in the docs that are calling the template's render method with a Context instance when they should use a regular dict.

I found these by searching with the following commands:

cd docs
git grep 'render.*Context'
git grep 'from django.*import.*Context'

Those grep commands also return results from ref/templates/api.txt, but they are ok because they use t = Template() instead of loader.get_template().

Change History (16)

comment:1 by Alasdair Nicol, 4 years ago

Pull request for sites docs: https://github.com/django/django/pull/11984

comment:2 by Alasdair Nicol, 4 years ago

Component: UncategorizedDocumentation
Keywords: Context render template added
Version: 2.2master

comment:3 by Claude Paroz, 4 years ago

Triage Stage: UnreviewedAccepted

For the auto-escaping case, the solution I'm using is to define a custom template engine with OPTIONS containing 'autoescape': False,. I don't know if this is the recommended new way of doing what the current example does.

comment:4 by Mariusz Felisiak, 4 years ago

Type: UncategorizedCleanup/optimization

comment:5 by Carlos_Mir_de_Souza, 4 years ago

Has patch: set
Patch needs improvement: set

The PR does not pass the checks, please update the PR.

comment:6 by Mariusz Felisiak, 4 years ago

Patch needs improvement: unset

Tests failures are not related.

comment:7 by Mariusz Felisiak, 4 years ago

Has patch: unset

comment:8 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

In b991eefd:

Refs #30923 -- Fixed an example of rendering templates in contrib.sites docs.

comment:9 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

In 78fc0530:

[3.0.x] Refs #30923 -- Fixed an example of rendering templates in contrib.sites docs.

Backport of b991eefd3a9fa4da4eb46fddcb36cf1e8b5862e9 from master

comment:10 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

In 406fb336:

[2.2.x] Refs #30923 -- Fixed an example of rendering templates in contrib.sites docs.

Backport of b991eefd3a9fa4da4eb46fddcb36cf1e8b5862e9 from master

comment:11 by Carlos_Mir_de_Souza, 4 years ago

Has patch: set
Resolution: fixed
Status: newclosed
Triage Stage: AcceptedReady for checkin

The patch was applied to master, im closing the ticket.

comment:12 by Mariusz Felisiak, 4 years ago

Has patch: unset
Resolution: fixed
Status: closednew
Triage Stage: Ready for checkinAccepted

Please don't close tickets that are not fixed. howto/custom-template-tags.txt is waiting for a fix.

comment:13 by Daniel Rios, 4 years ago

Owner: changed from nobody to Daniel Rios
Status: newassigned

comment:14 by Mariusz Felisiak, 2 years ago

Owner: Daniel Rios removed
Status: assignednew

comment:15 by Sean Bermejo, 2 years ago

Has patch: set

I created a PR for the custom template tags docs: https://github.com/django/django/pull/15495

comment:16 by Mariusz Felisiak, 2 years ago

Description: modified (diff)
Resolution: fixed
Status: newclosed

Examples in howto/custom-template-tags.txt work with Context(). Closing as fixed.

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