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
Source:stackexchange.com