Code

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#2966 closed enhancement (fixed)

[PATCH] add extra_context parameter to django.views.generic.direct_to_template

Reported by: wam-djangobug@… Owned by: jacob
Component: Generic views Version: master
Severity: normal Keywords: extra_context
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

There is currently no way to pass directly "top-level" context variables to the direct_to_template() generic view. Additional parameters sent via keyword arguments to the view are currently passed into the context accessible via the 'params' dictionary. If a base template for an application requires a particular context variable though, there is no way to get that variable defined with direct_to_template as it is now. The attached patch adds extra_context, which adds the specified dictionary values into context of the template directly, without having to indirect through 'params'. It is backwards compatible with the current direct_to_template invocation as well, as any keyword arguments other than 'extra_context' will still end up in the 'params' dictionary. This patch makes direct_to_template() behave more like the other generic views.

Attachments (1)

direct_to_template-extra_context.patch (867 bytes) - added by wam-djangobug@… 7 years ago.
patch to add extra_context param to direct_to_template() generic view

Download all attachments as: .zip

Change History (3)

Changed 7 years ago by wam-djangobug@…

patch to add extra_context param to direct_to_template() generic view

comment:1 Changed 7 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

(In [3950]) Fixes #2966 -- Added extra_context parameter to direct_to_template generic view to keep it aligned with capabilities of other generic views. Thanks, wam-djangobug@….

comment:2 Changed 7 years ago by adrian

(In [3953]) Added note to docs/generic_views.txt that extra_context is new in Django development version. Refs #2966 and [3950]

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.