Hi all,

after digging a bit deeper, it seems that

        ModelAdmin.save_formset()
        
<https://docs.djangoproject.com/en/1.4/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_formset>

is the right solution for my original problem (https://groups.google.com/d/topic/django-users/ZwgW7-t6CBA/discussion).

From there I followed to

        "Saving objects in the formset"
        
<https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#saving-objects-in-the-formset>


Now my question is, in the example for ModelAdmin.save_formset(), after the call to

    instances = formset.save(commit=False)

of what type is `instances`?  A list? A QuerySet?

Is it safe to sort the instances? E.g. like this:

    instances = formset.save(commit=False)

    for vv in instances.sort(key=lambda obj: obj.begin, reverse=True):
        # ...
        vv.save()

    formset.save_m2m()

(Being able to sort the instances in reverse order by "begin" date is required to solve my original problem...)

Finally, does `instances` contain only the instances that were changed/edited by the user, or all instances (that are related to the parent model)? (The latter is what I need...)

I tried this out as outlined above, and it seems that only changed instances are in `instances` (when no instances were changed, I get "TypeError: 'NoneType' object is not iterable", and find that `instances == []`...)


Any help would very much be appreciated!

Best regards,
Carsten


--
   Cafu - the open-source Game and Graphics Engine
for multiplayer, cross-platform, real-time 3D Action
          Learn more at http://www.cafu.de

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to