Python 使用prepend_URL添加的Tastypie列表端点
我试图找出如何从我编写的API中显示所有端点。在浏览API的根目录时,我看到了一个资源列表和一个get端点。如何生成显示所有端点的列表?我试过django tastypie招摇过市,但结果是一样的。它只列出了每个资源的几个GET方法,没有显示我添加到资源中的所有prepend_URL。感谢您的帮助 编辑: 我在get_manufacturer_楔子中有一些帮助方法来帮助响应。顺便说一句,我对python和整个堆栈非常陌生。我来自c#net的背景。我正在开发一个高尔夫应用程序Python 使用prepend_URL添加的Tastypie列表端点,python,django,tastypie,Python,Django,Tastypie,我试图找出如何从我编写的API中显示所有端点。在浏览API的根目录时,我看到了一个资源列表和一个get端点。如何生成显示所有端点的列表?我试过django tastypie招摇过市,但结果是一样的。它只列出了每个资源的几个GET方法,没有显示我添加到资源中的所有prepend_URL。感谢您的帮助 编辑: 我在get_manufacturer_楔子中有一些帮助方法来帮助响应。顺便说一句,我对python和整个堆栈非常陌生。我来自c#net的背景。我正在开发一个高尔夫应用程序 class Manu
class ManufacturerResource(BaseMongoResource):
class Meta:
max_limit = 0
queryset = Manufacturer.objects.all().order_by('id')
allowed_methods = ('get')
resource_name = 'manufacturers'
include_resource_uri = False
def prepend_urls(self):
return [
url(r"^(?P<resource_name>%s)/(?P<pk>[\w\d_.-]+)/wedges/$" % self._meta.resource_name,
self.wrap_view('get_manufacturer_wedges'), name="api_get_manufacturer_wedges"),
]
def get_manufacturer_wedges(self, request, **kwargs):
prim_key = kwargs['pk'] + "|Wedge"
wedges = Club.objects(_id__startswith=prim_key).order_by('name')
return self.create_response(request, HelperMethods.obj_to_list(wedges))
你有一些示例代码可以展示吗?@Joel我添加了一些源代码。prepend_URL中还有几个端点,但我只是删除了它们,因为它们都是使用不同的动词(“驱动程序”、“推杆”等)编写的。诚然,当我调用这些端点时,它们的工作和功能都很好,但我想为它们创建一些类型的文档。所以把所有的路线都吐出来就足够了。谢谢
{
"file_upload" : {
"schema" : "/api/v1/file_upload/schema/",
"list_endpoint" : "/api/v1/file_upload/"
},
"members" : {
"schema" : "/api/v1/members/schema/",
"list_endpoint" : "/api/v1/members/"
},
"manufacturers" : {
"schema" : "/api/v1/manufacturers/schema/",
"list_endpoint" : "/api/v1/manufacturers/"
},
"courses" : {
"schema" : "/api/v1/courses/schema/",
"list_endpoint" : "/api/v1/courses/"
},
"clubs" : {
"schema" : "/api/v1/clubs/schema/",
"list_endpoint" : "/api/v1/clubs/"
}
}