简体   繁体   English

Django-tastypie:如何以编程方式进行ModelResource?

[英]Django-tastypie: how to ModelResource programmatically?

I have created a number of Django-tastypie resource definitions in resources.py. 我在resources.py中创建了许多Django-tastypie资源定义。 Most of them will be created by posting from javascript side (backbone-tastypie), but some of them I would like to be able to create right from python code/django views. 它们中的大多数将通过从javascript端(backbone-tastypie)发布来创建,但是我希望其中一些能够直接从python代码/ django视图创建。 The reason for this is that object creation logic should be kept in one place, as well as authorization params. 这样做的原因是对象创建逻辑以及授权参数都应放在一个地方。

Is there some neat way to create TastyPie ModelResource inside Python code? 有一些巧妙的方法可以在Python代码中创建TastyPie ModelResource吗? (may be making a "post" with "Requests" module?). (可能是通过“请求”模块进行“发布”?)。

如果我理解正确,那么您的用例将在好吃的食谱中描述: http ://django-tastypie.readthedocs.org/en/latest/cookbook.html#using-your-resource-in-regular-views

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM