Better strategy to updates sites m2m
This commit is contained in:
parent
c5668bf943
commit
ea66bd3481
1 changed files with 3 additions and 1 deletions
|
@ -219,7 +219,9 @@ class PostAdmin(PlaceholderAdminMixin, FrontendEditableAdminMixin,
|
||||||
).difference(removed).union(form_sites)
|
).difference(removed).union(form_sites)
|
||||||
form.cleaned_data['sites'] = diff_original
|
form.cleaned_data['sites'] = diff_original
|
||||||
else:
|
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)
|
super(PostAdmin, self).save_related(request, form, formsets, change)
|
||||||
|
|
||||||
class Media:
|
class Media:
|
||||||
|
|
Loading…
Reference in a new issue