本文整理汇总了Python中tastypie.resources.ModelResource.api_field_from_django_field方法的典型用法代码示例。如果您正苦于以下问题:Python ModelResource.api_field_from_django_field方法的具体用法?Python ModelResource.api_field_from_django_field怎么用?Python ModelResource.api_field_from_django_field使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tastypie.resources.ModelResource
的用法示例。
在下文中一共展示了ModelResource.api_field_from_django_field方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: api_field_from_django_field
# 需要导入模块: from tastypie.resources import ModelResource [as 别名]
# 或者: from tastypie.resources.ModelResource import api_field_from_django_field [as 别名]
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)
示例2: test_model_resource_correct_association
# 需要导入模块: from tastypie.resources import ModelResource [as 别名]
# 或者: from tastypie.resources.ModelResource import api_field_from_django_field [as 别名]
def test_model_resource_correct_association(self):
api_field = ModelResource.api_field_from_django_field(models.DecimalField())
self.assertEqual(api_field, DecimalField)
示例3: api_field_from_django_field
# 需要导入模块: from tastypie.resources import ModelResource [as 别名]
# 或者: from tastypie.resources.ModelResource import api_field_from_django_field [as 别名]
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)