How to use the djangoql.schema.StrField function in djangoql

To help you get started, we’ve selected a few djangoql examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ivelum / djangoql / djangoql / schema.py View on Github external
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
github ivelum / djangoql / djangoql / schema.py View on Github external
return
            field_cls = RelationField
            field_kwargs['related_model'] = field.related_model
        else:
            field_cls = self.get_field_cls(field)
        if isinstance(field, (ManyToOneRel, ManyToManyRel, ForeignObjectRel)):
            # Django 1.8 doesn't have .null attribute for these fields
            field_kwargs['nullable'] = True
        else:
            field_kwargs['nullable'] = field.null
        field_kwargs['suggest_options'] = (
            field.name in self.suggest_options.get(model, [])
        )
        field_instance = field_cls(**field_kwargs)
        # Check if suggested options conflict with field type
        if field_cls != StrField and field_instance.suggest_options:
            for option in field_instance.get_options():
                if isinstance(option, text_type):
                    # Convert to StrField
                    field_instance = StrField(**field_kwargs)
        return field_instance
github ivelum / djangoql / djangoql / schema.py View on Github external
field_cls = self.get_field_cls(field)
        if isinstance(field, (ManyToOneRel, ManyToManyRel, ForeignObjectRel)):
            # Django 1.8 doesn't have .null attribute for these fields
            field_kwargs['nullable'] = True
        else:
            field_kwargs['nullable'] = field.null
        field_kwargs['suggest_options'] = (
            field.name in self.suggest_options.get(model, [])
        )
        field_instance = field_cls(**field_kwargs)
        # Check if suggested options conflict with field type
        if field_cls != StrField and field_instance.suggest_options:
            for option in field_instance.get_options():
                if isinstance(option, text_type):
                    # Convert to StrField
                    field_instance = StrField(**field_kwargs)
        return field_instance