Code

Changes between Initial Version and Version 2 of Ticket #11807


Ignore:
Timestamp:
08/31/09 07:43:35 (5 years ago)
Author:
kmtracey
Comment:

First, I fixed the description formatting. Please use preview (and wiki format) to make sure things are readable before submitting.

Replying to AdamG:

My guess is that BaseModelFormSet.save_existing_objects() is skipping the form because form.has_changed() is False.

Yes the problem is likely related to the fact that the form has not been changed, though I think it is the has_changed in save_new that is causing the issue here. Thing is, if nothing has changed, how is the admin code supposed to figure out that a new item should be created? I don't believe it is always the case that you'd want admin creating objects with all defaults (actually I'm pretty sure there was once a bug because admin did that). I am not sure that the admin interface, as it currently exists, supports what is being asked for here. There is currently no explicit "add this item" checkbox (as there is for delete), thus the admin has to figure out the right thing to do. It does that now by seeing if anything has changed since the form was presented to the user. If yes, then an object is added. If no, then no new object is created. I don't quite see how to support this use case, and also the case where you don't want all-default objects created (which is also valid), without a pretty significant change in the admin interface here.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #11807

    • Property Patch needs improvement set
    • Property Component changed from Uncategorized to django.contrib.admin
    • Property Needs tests unset
    • Property Needs documentation unset
    • Property Triage Stage changed from Unreviewed to Design decision needed
  • Ticket #11807 – Description

    initial v2  
    33I have the following models: 
    44 
     5{{{ 
     6#!python 
    57class A(models.Model): 
    68   id = models.AutoField(primary_key=True) 
     
    911   mya = models.OneToOneField(A, primary_key=True) 
    1012   text = models.TextField(default='Init') 
     13}}} 
    1114 
    1215In admin interface, I have used an inline to include B when