Hello folks,
Is it possible to return object instead of id on foreign relation with annotate? eg:
class Times(models.Model)
employee = models.ForeignKey(Employee,...
class Viewset()
def get_queryset(self):
return (
super()
.get_queryset()
.select_related("employee__user")
.annotate(employee_full_name=Concat("employee__user__first_name", Value(" "), "employee__user__last_name", output_field=CharField()))
).order_by("-start_stamp")
what i need:
employee:{
"id",
"full_name":"",
}