Code

Opened 6 years ago

Closed 6 years ago

Last modified 5 years ago

#7688 closed (invalid)

newforms-admin: need mechanism for further modifying a newly saved object after it has been saved

Reported by: simon Owned by: nobody
Component: contrib.admin Version: newforms-admin
Severity: Keywords:
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by simon)

ModelAdmin.save_add(...) creates a new_object and then returns an HttpResponseRedirect(). It would be really useful if there was a hook for further modifying that object after it had been saved.

It's possible to do this using a custom save() method on the model at the moment, but that has two limitations:

  1. The save() method doesn't have access to a request object. Admin customisations often involve extra form stuff being passed in as part of the request.
  1. You might want custom behaviour that only runs on objects created using the admin, not objects created using other means.

Having a post_save_add() method that is passed the request and the newly created object and does nothing by default (but can be over-ridden in ModelAdmin subclasses) would be one way of solving this, but I'm not sure it's the best way.

Attachments (0)

Change History (5)

comment:1 Changed 6 years ago by simon

  • Description modified (diff)

comment:2 Changed 6 years ago by ericholscher

  • milestone set to post-1.0
  • Triage Stage changed from Unreviewed to Design decision needed

comment:3 Changed 6 years ago by peritus <peritus@…>

I think this is obsolete. One can use ModelAdmin.response_add for intercepting the data:

def response_add(self, request, obj, *args, **kwargs):
    response = super(MyModelAdmin, self).response_add(request, obj, *args, **kwargs)

    if request.method == 'POST':
        obj.do_something()

    return response

Can someone close this, if there are no objections ?

comment:4 Changed 6 years ago by brosner

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

Yes, all the new hooks on ModelAdmin have solved this problem. Marking invalid as it is no longer valid :)

comment:5 Changed 5 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

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.