[Answered ]-How do you edit a many to many field in Django during save?

1👍

You can override the save_related(…) method [Django-doc] of your ModelAdmin and set the is_active field to True with a single query:

class SectorAdmin(ModelAdmin):

    # …

    def save_related(self, request, form, formsets, change):
        super().save_related(request, form, formsets, change)
        form.instance.featured_companies.all().update(
            is_active=True
        )

Leave a comment