Answer the question
In order to leave comments, you need to log in
Why is m2m_changed called when there is no connection yet?
There are two related models
class Tag(models.Model):
pass
class Photo(models.Model):
tags = models.ManyToManyField(Tag, related_name='tags', blank=True)
@receiver(m2m_changed, sender=Photo.tags.through)
def photo_tags_changed(sender, instance, action, **kwargs):
print( action, kwargs, instance.tags.all())
post_add {'pk_set': {28538}, 'using': 'default', 'reverse': False, 'model': <class 'apps.photos.models.Tag'>, 'signal': <django.db.models.signals.ModelSignal object at 0x7fc890ddda20>} []
class PhotoWriteSerializer(serializers.ModelSerializer):
class Meta:
model = Photo
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question