From 3b246b66bdd7993c861ae2542eb40cd8c7d35a11 Mon Sep 17 00:00:00 2001 From: Slava Date: Mon, 21 Aug 2017 13:29:41 +0300 Subject: [PATCH] fix save m2m at admin --- apps/expobanner/forms.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/expobanner/forms.py b/apps/expobanner/forms.py index 2e5e4e82..13794d51 100644 --- a/apps/expobanner/forms.py +++ b/apps/expobanner/forms.py @@ -314,6 +314,11 @@ class MainUpdateForm(forms.ModelForm): class TopMixinForm(forms.ModelForm, FieldsetMixin): cities = forms.CharField(label=_(u'Город'), widget=forms.HiddenInput() ,required=False) + country = forms.MultipleChoiceField( + label=u'Страны', + choices=[[x.pk, x.name] for x in list(set(Country.objects.all()))], + required=False + ) class Meta: model = Top @@ -356,6 +361,9 @@ class TopMixinForm(forms.ModelForm, FieldsetMixin): old_save_m2m = self.save_m2m def save_m2m(): + print 111111111 + print self + print self.cleaned_data['country'] old_save_m2m() # This is where we actually link the pizza with toppings top.theme.clear()