Opened 2 years ago

Closed 2 years ago

#20558 closed New feature (fixed)

Add `response_delete` and `render_delete_form` methods to `ModelAdmin`

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

Description

Background:

  • It is currently quite easy to set up custom redirects after saving a new or changed object, by overriding response_add() or response_change()
  • I suggest to add a response_delete() method to ModelAdmin, called from delete_view()

Change History (7)

comment:1 Changed 2 years ago by charettes

  • Easy pickings set
  • Needs documentation set
  • Needs tests set
  • Patch needs improvement unset
  • Summary changed from Suggestion: In ModelAdmin add a response_delete() method to Add `response_delete` and `render_delete_form` methods to `ModelAdmin`
  • Triage Stage changed from Unreviewed to Accepted
  • Version changed from 1.5 to master

This feature addition makes sense -- I've hit this limitation in the past.

I will mark as easy picking since it's really just code moving, simple tests and documentation writing.

Also, it might be worth adding a render_delete_form method while we're here, to be consistent with add_view (response_add/render_change_form(add=True)) and change_view (response_change, render_change_form(add=False)).

comment:2 Changed 2 years ago by zyegfryed

  • Owner changed from nobody to zyegfryed
  • Status changed from new to assigned

comment:3 Changed 2 years ago by zyegfryed

As far as I've checked, there's no documentation for response_add/response_change/render_change_form. Shall we add some within this ticket?
Also, there's only one test for all the mentioned hooks, targeting only the post_url_continue parameter form response_add method. Shall we add some more?
If so, where should we put them? In tests/admin/custom_urls? Another app?
Thanks for your feedback.

comment:4 Changed 2 years ago by polmuz

  • Owner changed from zyegfryed to polmuz

Since this been quiet for a couple of months, I started to work on it. Here is the pull request: https://github.com/django/django/pull/1583

comment:5 Changed 2 years ago by polmuz

  • Has patch set
  • Needs tests unset

comment:6 Changed 2 years ago by polmuz

  • Cc polmuz added

comment:7 Changed 2 years ago by jacob

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

Fixed in 9079436 and 73de9dd.

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