Skip to content

Instantly share code, notes, and snippets.

@katiayn
Last active May 12, 2017 08:57
Show Gist options
  • Save katiayn/c3e7b612d43b641314e93df31ae69d36 to your computer and use it in GitHub Desktop.
Save katiayn/c3e7b612d43b641314e93df31ae69d36 to your computer and use it in GitHub Desktop.
class ProductQuestionnaireForm(forms.ModelForm):
class Meta:
model = ProductQuestionnaire
exclude = (
'id',
'product',
)
def save(self, commit=True):
instance = super().save(commit)
is_biscuit = self.cleaned_data.get('is_biscuit')
is_coated_in_chocolate = self.cleaned_data.get('is_coated_in_chocolate')
if is_biscuit and is_coated_in_chocolate:
instance.product.set_vat_20()
return instance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment