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):
filtered.
"""
return query.annotate(
full_name=Concat(
"author__username",
V("/"),
"name",
V("/"),
"version",
output_field=CharField(),
)
)
args = ["name", V("/"), "version"]
if hasattr(query.model, "author"):
args = ["author__username", V("/")] + args
return query.annotate(full_name=Concat(*args, 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