本文整理匯總了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)