From ea66bd3481ba3038fa87770d81e42f7c621d988f Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Thu, 2 Jun 2016 22:12:43 +0200 Subject: [PATCH] Better strategy to updates sites m2m --- djangocms_blog/admin.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/djangocms_blog/admin.py b/djangocms_blog/admin.py index 0fc3c00..1e834bc 100755 --- a/djangocms_blog/admin.py +++ b/djangocms_blog/admin.py @@ -219,7 +219,9 @@ class PostAdmin(PlaceholderAdminMixin, FrontendEditableAdminMixin, ).difference(removed).union(form_sites) form.cleaned_data['sites'] = diff_original else: - form.cleaned_data['sites'] = self.get_restricted_sites(request).all() + form.instance.sites.add( + *self.get_restricted_sites(request).all().values_list('pk', flat=True) + ) super(PostAdmin, self).save_related(request, form, formsets, change) class Media: