Commit c7ad3889 authored by Samuel GAIST's avatar Samuel GAIST

[common][utils] Support authorless models in annotate_full_name

parent 291004e3
...@@ -154,13 +154,9 @@ def annotate_full_name(query): ...@@ -154,13 +154,9 @@ def annotate_full_name(query):
filtered. filtered.
""" """
return query.annotate( args = ["name", V("/"), "version"]
full_name=Concat(
"author__username", if hasattr(query.model, "author"):
V("/"), args = ["author__username", V("/")] + args
"name",
V("/"), return query.annotate(full_name=Concat(*args, output_field=CharField()))
"version",
output_field=CharField(),
)
)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment