简体   繁体   English

angucomplete + Django-rest-framework

[英]angucomplete + django-rest-framework

I want to use Django-REST-Framework as backend for angucomplete. 我想将Django-REST-Framework用作angucomplete的后端。 The problem is that DRF returns a list of objects straight away without wrapping it in a dictionary (response is something like [item, item, item] instead of {results: [item, item, item]}) and I don't know how to teel angucomplete where to look for the list. 问题在于DRF会立即返回一个对象列表,而没有将其包装在字典中(响应类似于[item,item,item],而不是{results:[item,item,item]})),我不知道如何在清单上查找angucomplete。

I know I can tinker with fields and serializers but I want to keep things as simple as it is possible, without any additional boilerplate. 我知道我可以修改字段和序列化器,但我想尽可能地简化事情,而无需任何额外的模板。

Any hints? 有什么提示吗?

What calls are you making to DRF that returns that result object? 您要对返回该结果对象的DRF进行什么调用?

If you have paginated results (and you should) the result objects should be like the following: 如果您有分页的结果(并且应该),则结果对象应类似于以下内容:

{ "results": [ ... ] }

You can read more about paginated results in the DRF documentation . 您可以在DRF文档中阅读有关分页结果的更多信息。

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

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