[Answered ]-Save method manytomany

2👍

Are you using the django-admin to save the model and tags? The many-to-many fields don’t get saved there until after the post-save signal of the model. What you can do in this case is overide the admin classes save_model method. E.g.:

class CardAdmin(admin.ModelAdmin):

    def save_model(self, request, obj, form, change):
        obj.save()
        form.save_m2m()
        #from this point on the tags are accessible
        print obj.tags.all()
👤d-vine

0👍

You aren’t adding any tags to the Card. You can’t add ManyToMany relationships until after you save the Card, and there’s no time between the save call and the call to self.tags.all() for them to be set.

Leave a comment