相关疑难解决方法(0)

一个信号m2m_changed和post_remove的bug

我需要检测一个post_remove信号,所以我写了:

def handler1(sender, instance, action, reverse, model, pk_set, **kwargs):
if (action == 'post_remove'):
    test1()  # not declared but make a bug if it works, to detect :)

m2m_changed.connect(handler1, sender=Course.subscribed.through)
Run Code Online (Sandbox Code Playgroud)

如果我用'post_add'改变'post_remove'就可以了..这是关于post_remove的django的错误吗?

我使用该模型并在两个'subscribed'值之间切换(所以添加一个,删除一个)

class Course(models.Model):
    name = models.CharField(max_length=30)
    subscribed = models.ManyToManyField(User, related_name='course_list', blank=True, null=True, limit_choices_to={'userprofile__status': 'student'})
Run Code Online (Sandbox Code Playgroud)

我看过一篇有django错误的帖子,也许它还没有被修复......(或者它是我^^)

django django-signals

6
推荐指数
2
解决办法
2302
查看次数

标签 统计

django ×1

django-signals ×1