Opened 8 years ago

Closed 4 years ago

Last modified 22 months ago

#5298 closed (fixed)

The extra_context keyword argument should be available in the auth app views

Reported by: peadalo@… Owned by: durdinator
Component: Contrib apps Version: master
Severity: Keywords: extra_context auth "generic views" sprintsept14
Cc: adurdin@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Enhancement Request

When using the views in the auth app (django.contrib.auth.views), it would be nice to have the option of passing extra context variables through the views and to the templates. This seems to be possible with django generic views by passing a dictionary to the "extra_context" keyword argument.

This would be useful for passing context variables to the login/logout templates which are specific to only those templates and therefore don't belong in the RequestContext context processors.

Attachments (6)

fix-extra_context.diff (3.9 KB) - added by jordanl 8 years ago.
Adds support for passing extra_context to the views in django.contrib.auth.views
patch_5298.diff (5.1 KB) - added by durdinator 8 years ago.
patch_5298.2.diff (5.1 KB) - added by durdinator 8 years ago.
django.contrib.auth.views.patch (4.5 KB) - added by Jj <jjdelc@…> 7 years ago.
extra_context added to views
contrib_auth_views_extra_context.patch (5.9 KB) - added by efloehr 5 years ago.
Patch for extra_context, current as of changeset [13042]
auth-extra-content-14586.diff (6.4 KB) - added by adamv 5 years ago.
Patch updated to r14586

Download all attachments as: .zip

Change History (25)

comment:1 Changed 8 years ago by Simon G. <dev@…>

  • Component changed from Uncategorized to Metasystem
  • Needs documentation unset
  • Needs tests unset
  • Owner changed from jacob to adrian
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed
  • Version changed from 0.96 to SVN

Want to write a patch?

comment:2 Changed 8 years ago by russellm

  • Component changed from Metasystem to Contrib apps
  • Triage Stage changed from Design decision needed to Accepted

Seems like a reasonable idea.

comment:3 Changed 8 years ago by durdinator

  • Owner changed from nobody to durdinator

Changed 8 years ago by jordanl

Adds support for passing extra_context to the views in django.contrib.auth.views

comment:4 Changed 8 years ago by jordanl

  • Has patch set

comment:5 Changed 8 years ago by jordanl

The patch is pretty trivial. Not sure if this even needs tests.

Changed 8 years ago by durdinator

Changed 8 years ago by durdinator

comment:6 Changed 8 years ago by durdinator

patch_5298.diff has the same semantics for extra_context as the generic views: i.e. it calls callables in the dict.

patch_5298.2.diff adds a paragraph to the docs about it.

comment:7 Changed 8 years ago by gkelly

  • Keywords sprintsept14 added

comment:8 Changed 8 years ago by Simon G. <dev@…>

  • Triage Stage changed from Accepted to Ready for checkin

comment:9 Changed 8 years ago by russellm

  • Triage Stage changed from Ready for checkin to Accepted

Mostly fine - but why the 'update_context_from_dict' method? Why not just use Context.update()?

comment:10 Changed 8 years ago by durdinator

  • Cc adurdin@… added

I was following the example of the extra_context argument to generic views, whereby callables are called -- for comparison see http://code.djangoproject.com/browser/django/trunk/django/views/generic/list_detail.py#L88

Changed 7 years ago by Jj <jjdelc@…>

extra_context added to views

comment:11 Changed 7 years ago by Jj <jjdelc@…>

I just added the django.contrib.auth.views.patch patch that adds extra_context support to the auth views, It has minimal impact in the overall code and should not affect current code.

comment:12 Changed 5 years ago by CrashRoX

  • Version changed from SVN to 1.1

This is still not as of 1.1...
(r'login/$', 'django.contrib.auth.views.login', {'template_name': 'login.html', 'extra_context': {'test': 'test'}})

comment:13 Changed 5 years ago by lukeplant

The patch should use None, not {} as default value, due to potential 'mutable defaults' issue.

comment:14 follow-up: Changed 5 years ago by efloehr

  • Version changed from 1.1 to SVN

This patch no longer works with trunk, due to changes in auth. I've attached an updated patch, current as of [12938]. I've also changed the patch to default extra_context to None instead of the original {}, as suggested by lukeplant in previous comment. I've also changed version to SVN as this patch isn't in 1.1.

Changed 5 years ago by efloehr

Patch for extra_context, current as of changeset [13042]

comment:15 in reply to: ↑ 14 Changed 5 years ago by efloehr

Replying to efloehr:
Patch current as of [13042].

Changed 5 years ago by adamv

Patch updated to r14586

comment:16 Changed 4 years ago by jezdez

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

(In [14768]) Fixed #5298 -- Added extra_context to contrib auth views.

comment:17 Changed 22 months ago by Tim Graham <timograham@…>

In 61ecb5f48a4732f1471f858c64904ec1c4763925:

Fixed #20855 -- Added documentation of current_app and extra_context params to django.contrib.auth views

refs #5298 and refs #8342

comment:18 Changed 22 months ago by Tim Graham <timograham@…>

In 77293f9354774e2631087935f1550c674093c433:

[1.6.x] Fixed #20855 -- Added documentation of current_app and extra_context params to django.contrib.auth views

refs #5298 and refs #8342

Backport of 61ecb5f48a from master

comment:19 Changed 22 months ago by Tim Graham <timograham@…>

In 145e0a14f0c098d7bbf2bfb593f7b6cfe1b02d72:

[1.5.x] Fixed #20855 -- Added documentation of current_app and extra_context params to django.contrib.auth views

refs #5298 and refs #8342

Backport of 61ecb5f48a from master.

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