My model has a save() override, in which a number of attributes (which
are ManyToManyFields) need to get their values from the object's parent:

    def save(self):
        if self.parent:
            attribute_list = ['publishing_destinations',
'registration_enquiries', 'speakers', 'related_people', 'related_pages',
'related_events', 'related_newsarticles',]
            for attribute in attribute_list:
                if not getattr(self, attribute).all():
                    setattr(self, attribute, getattr(self.parent,
attribute).all())
        super(Event, self).save()

These attributes don't survive the save() though (because they contain
many-to-many relations, the object needs to be saved to the database
before such relations to it can exist).

So, obviously I need another stage, to save the many-to-many relations
once theo bject is saved. 

What is the best way to achieve that?

Thanks,

Daniele


--~--~---------~--~----~------------~-------~--~----~
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