Skip to content

Commit

Permalink
Better strategy to updates sites m2m
Browse files Browse the repository at this point in the history
  • Loading branch information
yakky committed Jun 2, 2016
1 parent c5668bf commit ea66bd3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion djangocms_blog/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,9 @@ def save_related(self, request, form, formsets, change):
).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:
Expand Down

0 comments on commit ea66bd3

Please sign in to comment.