Wednesday, June 23, 2010

Django ModelAdmin doesn't seem to save m2m fields with save_model

Hi,

I have some trouble understanding how ModelAdmin do save models when those have many to many fields.

Long story:
I have for one of my application overridden ModelAdmin class and the save_model.

Basicaly, the save_model is:

def save_model(self, request, obj, form, change):
super(TranslationAdmin, self).save_model(request, obj, form, change)
# Some other processing

However, I have noticed that if the object has a many to many field, it isn't saved.

I looked at ModelAdmin and BaseModelAdmin classes and all I saw is BaseModelAdmin doing a simple obj.save()
I just don't understand why my many to many fields aren't saved.

I added a form.save_m2m() in my save_model but I still don't understand why I need it.

Could someone help me understand or simply point me in a direction to look at please ?

Regards,
Xavier.

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment