Skip to content

Commit 5984099

Browse files
authored
Merge branch 'master' into pre-commit-ci-update-config
2 parents ca71ed9 + dfaa323 commit 5984099

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

djangocms_link/admin.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,35 @@ class AdminUrlsView(BaseListView):
3939

4040
def get(self, request, *args, **kwargs):
4141
"""
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:
4445
{
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}
4760
}
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+
}
4871
"""
4972
if request.GET.get("g"):
5073
# Get name of a reference

0 commit comments

Comments
 (0)