If you want to perform additional logic when you save your model...
   
class MyModel(models.Model):

    #...

    def save(self, *args, **kwargs):
        self.a_rel_model_set.add(O)
        super(MyModel, self).save(*args, **kwargs)
        self.another_rel_model_set.add(O2)

Or similar login in pre_save and post_save signals, since they are 
many2many fields, they will be overriden on an admin form, since the 
form.save_m2m is called *after* the model save, and whatever changes I do 
on those signals, will be wiped out.

The logic I had to put it in log_change (ModelAdmin method). I don't know 
whether it is the appropriate method, but is the first method executed 
*after* model saving. Is it the appropriate method for that? Admin 
post-save logic... or should we have an additional method in the admin for 
that?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2a1d230f-1dee-4f2b-8a07-3f9f06ee60e8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to