@@ -39,12 +39,35 @@ class AdminUrlsView(BaseListView):
39
39
40
40
def get (self , request , * args , ** kwargs ):
41
41
"""
42
- Return a JsonResponse with search results as defined in
43
- serialize_result(), by default:
42
+ Return a JsonResponse with search results (query parameter "q") usable by
43
+ Django admin's autocomplete view. Each item is returned as defined in
44
+ serialize_result(), for example:
44
45
{
45
- results: [{id: "123" text: "foo"}],
46
- pagination: {more: true}
46
+ "results": [
47
+ {
48
+ "text": "Page",
49
+ "children" : [
50
+ {
51
+ "id": "cms.page:5",
52
+ "text": "My first page",
53
+ "url": "/en/my-first-page/",
54
+ "verbose_name": "Pages",
55
+ }, ...
56
+ ]
57
+ }, ...
58
+ ],
59
+ "pagination": {"more": true}
47
60
}
61
+
62
+ If the endpoint is called with the query parameter "g" (for get), the view will
63
+ search for the id (e.g., "cms.page:5") and return its entry as defined in
64
+ serialize_results(), e.g.:
65
+ {
66
+ "id": "cms.page:5",
67
+ "text": "My first page",
68
+ "url": "/en/my-first-page/",
69
+ "verbose_name": "Pages",
70
+ }
48
71
"""
49
72
if request .GET .get ("g" ):
50
73
# Get name of a reference
0 commit comments