本文整理匯總了Python中tastypie.resources.ModelResource方法的典型用法代碼示例。如果您正苦於以下問題:Python resources.ModelResource方法的具體用法?Python resources.ModelResource怎麽用?Python resources.ModelResource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tastypie.resources
的用法示例。
在下文中一共展示了resources.ModelResource方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: tastypie_api
# 需要導入模塊: from tastypie import resources [as 別名]
# 或者: from tastypie.resources import ModelResource [as 別名]
def tastypie_api():
"""
Tastypie API as a lazy object because it needs to import User model which
can't be done until after django.setup()
"""
from django.contrib.auth.models import User
try:
from tastypie.api import Api as TastypieApi
from tastypie.resources import ModelResource as TastypieModelResource
except ImportError:
return None
class UserResource(TastypieModelResource):
class Meta:
queryset = User.objects.all()
allowed_methods = ["get"]
api = TastypieApi(api_name="v1")
api.register(UserResource())
return api