本文整理匯總了Python中djangorestframework.views.ListOrCreateModelView.get方法的典型用法代碼示例。如果您正苦於以下問題:Python ListOrCreateModelView.get方法的具體用法?Python ListOrCreateModelView.get怎麽用?Python ListOrCreateModelView.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類djangorestframework.views.ListOrCreateModelView
的用法示例。
在下文中一共展示了ListOrCreateModelView.get方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_colors_json
# 需要導入模塊: from djangorestframework.views import ListOrCreateModelView [as 別名]
# 或者: from djangorestframework.views.ListOrCreateModelView import get [as 別名]
def get_colors_json():
"""
This is a surprising kludge to get the json from a
DRF resource, outside of a true request/response context
for a simple resource - most easily mocked by doing list(queryset.values(fields))
"""
resource_view = ListOrCreateModelView(resource=ColorResource)
dummy_request = HttpRequest()
response_obj = resource_view.get(dummy_request)
response = Response(status.HTTP_200_OK, response_obj)
jsonr = JSONRenderer(resource_view)
filtered_content = resource_view.filter_response(response_obj)
# json_string = jsonr.render(filtered_content)
return filtered_content