def validate(self, attrs):
     # if phrase python is in title, language must be python as well
     language = attrs.get('language')
     title = attrs.get('title')
     if 'python' in title.lower() and language != 'python':
         raise ValidationError('Must be a python language')
     return attrs
Example #2
0
 def validate(self, attrs):
     # if phrase python is in title, language must be python as well
     language = attrs.get('language')
     title = attrs.get('title')
     if 'python' in title.lower() and language != 'python':
         raise ValidationError('Must be a python language')
     return attrs
Example #3
0
 def validate(self, attrs):
     # if phrase python is in title, language must be python as well
     language = attrs.get('language')
     title = attrs.get('title')
     if 'python' in title.lower() and language != 'python':
         self.register_error(error_message='Python, fool!',
                             error_key='invalid_choice',
                             field_name='language')
     return attrs
 def validate(self, attrs):
     # if phrase python is in title, language must be python as well
     language = attrs.get('language')
     title = attrs.get('title')
     if 'python' in title.lower() and language != 'python':
         self.register_error(error_message='Python, fool!',
                             error_key='invalid_choice',
                             field_name='language')
     return attrs