#11830: save_model in ModelAdmin and inline model formsets
----------------------------------+-----------------------------------------
 Reporter:  nfg                   |       Owner:  nobody    
   Status:  new                   |   Milestone:            
Component:  django.contrib.admin  |     Version:  1.1       
 Keywords:  save_model save       |       Stage:  Unreviewed
Has_patch:  1                     |  
----------------------------------+-----------------------------------------
 I tried to use the {{{save_model}}} in {{{ModelAdmin}}} to add and remove
 some related objects for the saved instance. But because
 {{{save_formset}}} is called after {{{save_model}}} a
 {{{ValidationError}}} is emitted. This happens because my code removes a
 related object expected by a {{{BaseInlineFormSet}}}. The reason I use
 {{{save_model}}} and not the save method on the model is because I need
 access to the request object. If, however, I did this in the {{{save}}}
 method of the model the error will still be the same. {{{save_formset}}}
 is called after {{{save_model}}} which call the {{{save}}} method on the
 model instance. If you remove a related object to a model instance
 expected by one of {{{ModelAdmin}}}'s related formsets you get an error.

 I have supplied a patch containing a test that trigger this error. I have
 also included a rater naive fix, which simply ignores related objects
 triggering {{{ValidationError}}} in {{{save_existing_object}}}. The
 exception is emitted in a context where it is not caught by the form
 handling code.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/11830>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to