-
-
Save maxwellamaral/76606ebad4b26aacac9a0efadc13c9d6 to your computer and use it in GitHub Desktop.
Campo requerido condicionado no Django
This file contains 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 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