Opened 6 years ago

Closed 5 years ago

Last modified 3 years ago

#10759 closed (duplicate)

UserAdmin views should use attribute or current model to lookup the template paths

Reported by: jturnbull Owned by: nobody
Component: contrib.admin Version: master
Severity: Keywords: UserAdmin, add_view, user_change_password
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

When overriding the add_view() and user_change_password() in UserAdmin I expected it to use the current model names to find the templates (like the rest of admin).

However, it was hardcoded to use admin/auth/user/add_form.html and admin/auth/user/change_password.html.

Attached patch adds in the path for the current model, falling back to the above for backwards compatibility.

Attachments (2)

admin_user_templates.diff (1.4 KB) - added by jturnbull 6 years ago.
admin_user_template_vars.diff (3.4 KB) - added by jturnbull 6 years ago.
More flexible version

Download all attachments as: .zip

Change History (14)

Changed 6 years ago by jturnbull

comment:1 Changed 6 years ago by Alex

  • milestone set to 1.2
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 6 years ago by jturnbull

Any chance this could get set for 1.1 rather than 1.2?

I only ask as it goes very well with my other (set for 1.1) patch here: #10694

comment:3 Changed 6 years ago by Alex

That's a bug, this is, in my view, a feature, admittingly a totally low overhead, noncontroversial no work one, but where that bar lies is for a committer to decide, so I've been intentionally rather conservative here.

comment:4 Changed 6 years ago by jturnbull

Cool, thanks for taking the time to explain.

Changed 6 years ago by jturnbull

More flexible version

comment:5 Changed 6 years ago by jturnbull

  • Summary changed from UserAdmin views should use the current model to lookup the template paths to UserAdmin views should use attribure or current model to lookup the template paths
  • Triage Stage changed from Accepted to Unreviewed

After thinking about this further, I've submitted a new patch and knocked this bug back to "Unreviewed". Apologies for messing it around.

Taking cues from ModelAdmin, this version first looks for local attributes add_form_template and change_password_template before then attempting the template based off the models name, and finally falling back to the auth.user template (for backwards compatiblity).

Also to follow the convention of ModelAdmin in this version I define a variable for the context and pass that into render_to_response rather than defining a variable for the templates as I did in the previous patch.

comment:6 Changed 6 years ago by jturnbull

  • Summary changed from UserAdmin views should use attribure or current model to lookup the template paths to UserAdmin views should use attribute or current model to lookup the template paths

Fixed a typo in the Summary.

comment:7 Changed 6 years ago by Alex

  • Triage Stage changed from Unreviewed to Accepted

comment:8 Changed 5 years ago by ubernostrum

  • milestone 1.2 deleted

1.2 is feature-frozen, moving this feature request off the milestone.

comment:9 Changed 5 years ago by jturnbull

  • milestone set to 1.3

This patch is ready to go and accepted - can someone push this into Django 1.3?

comment:10 Changed 5 years ago by jturnbull

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

This was mostly fixed in #12218, so closing as a dupe.

comment:11 Changed 5 years ago by jturnbull

Apologies, I meant: [12218]

comment:12 Changed 3 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

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