Skip to content

Instantly share code, notes, and snippets.

@maxwellcc
Created May 27, 2020 11:49
Show Gist options
  • Save maxwellcc/a07bbd1348dd62024237d5a2bd2777c5 to your computer and use it in GitHub Desktop.
Save maxwellcc/a07bbd1348dd62024237d5a2bd2777c5 to your computer and use it in GitHub Desktop.
Campo requerido condicionado
class ArticleForm(forms.ModelForm):
brief_summary = forms.CharField(
widget=TinyMCE(
attrs={
'cols': 80,
'rows': 50
}
)
)
class Meta:
model = Article
fields = ()
def clean(self):
data = self.cleaned_data
highlighted_article = data.get('highlighted_article')
image = data.get('image')
if highlighted_article and not image:
raise forms.ValidationError(_('Provide an image for highlighted article.'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment