Hi, I need to use the m2m_changed signal to assign permissions over an object. But somehow, I cannot make it work.
To summarise, my models.py is as follows: from cmsplugin_news.models import News from django.contrib.auth.models import Group from django.db import models from guardian.shortcuts import assign_perm, remove_perm class Department(models.Model): news = models.ManyToManyField( News, blank=True, related_name='departments' ) write_group = models.ForeignKey(Group, blank=True) @receiver(m2m_changed, sender=Department.news.through) def _m2m_changed_news_departments(sender, instance, action, reverse, model, pk_set, **kwargs): if action == "pre_add": for pk in pk_set: d = Department.objects.get(pk__exact=pk) assign_perm('cmsplugin_news.change_news', d.write_group, instance) assign_perm('cmsplugin_news.delete_news', d.write_group, instance) elif action == "pre_remove": for pk in pk_set: d = Department.objects.get(pk__exact=pk) remove_perm('cmsplugin_news.change_news', d.write_group, instance) remove_perm('cmsplugin_news.delete_news', d.write_group, instance) The point is that the signal is never caught. I am editing the m2m relation from the admin interface (as an inline in cmsplugin_news). When I add/delete a department from the formset, the signal is never caught by my method. Any help here? Thank you very much. Roberto -- 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 http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.