Ejemplo n.º 1
0
    def api_field_from_django_field(cls, f, default=fields.CharField):
        """
        Returns the field type that would likely be associated with each
        Django type.
        """
        result = default
        internal_type = f.get_internal_type()

        if internal_type in ('JSONField'):
            return JSONApiField
        else:
            return ModelResource.api_field_from_django_field(f, default)
    def api_field_from_django_field(cls, f, default=fields.CharField):
        """
        Returns the field type that would likely be associated with each
        Django type.
        """
        result = default
        internal_type = f.get_internal_type()

        if internal_type in ('JSONField'):
            return JSONApiField
        else:
            return ModelResource.api_field_from_django_field(f, default)
Ejemplo n.º 3
0
 def api_field_from_django_field(cls, f, default=fields.CharField):
     # TODO: extensions
     r = ModelResource.api_field_from_django_field(f, default=default)
     return r
Ejemplo n.º 4
0
 def test_model_resource_correct_association(self):
     api_field = ModelResource.api_field_from_django_field(models.DecimalField())
     self.assertEqual(api_field, DecimalField)
Ejemplo n.º 5
0
 def test_model_resource_correct_association(self):
     api_field = ModelResource.api_field_from_django_field(
         models.DecimalField())
     self.assertEqual(api_field, DecimalField)
Ejemplo n.º 6
0
 def api_field_from_django_field(cls, f, **kwargs):
     internal_type = f.get_internal_type()
     if internal_type == "BigIntegerField":
         return fields.IntegerField
     return ModelResource.api_field_from_django_field(f, **kwargs)