[Answer]-How to do the validation for two forms in django

1👍

You can override the clean() method of your model forms to perform validation that requires knowledge of a broader scope.

In your case, you might do

def clean(self):
   if not Course.objects.count() and not self.cleaned_data['course_name']:
       raise ValidationError(u"Some sensible message")
   return self.cleaned_data
👤guyrt

Leave a comment