Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_field_cls(self, field):
str_fields = (models.CharField, models.TextField, models.UUIDField)
if isinstance(field, str_fields):
return StrField
elif isinstance(field, (models.AutoField, models.IntegerField)):
return IntField
elif isinstance(field, (models.BooleanField, models.NullBooleanField)):
return BoolField
elif isinstance(field, (models.DecimalField, models.FloatField)):
return FloatField
elif isinstance(field, models.DateTimeField):
return DateTimeField
elif isinstance(field, models.DateField):
return DateField
return DjangoQLField
def validate(self, value):
super(DateTimeField, self).validate(value)
try:
self.get_lookup_value(value)
except ValueError:
raise DjangoQLSchemaError(
'Field "%s" can be compared to timestamps in '
'"YYYY-MM-DD HH:MM" format, but not to %s' % (
self.name,
repr(value),
)