-
-
Save antdking/58802e43f06b555b2955fe28c76324ea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OrderForm(forms.ModelForm): | |
class Meta: | |
model = Order | |
fields = ['book_title', 'customer', 'internal_design', 'paid', 'start_date'] | |
campaign = forms.ModelMultipleChoiceField(queryset=Campaign.objects.all()) | |
def _save_m2m(self): | |
super()._save_m2m() | |
campaign = Campaign.objects.get(pk=self.cleaned_data['campaign']) | |
for producttype in campaign.product_types.all(): | |
Product.objects.get_or_create( | |
order=self.instance, | |
product_type=producttype) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment