Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I get an error when return a queryset objects: Cannot resolve expression type, unknown output_field

I'm need annotation each object in queryset. I used annotation, but when return modified object, I get this error:

Cannot resolve expression type, unknown output_field.

How can I solve this problem?

def get_queryset(self):
   get_cinema = Ciname.objects.filter(active_cinema='t')
   distation = 54.87 #for example
   queryset = get_cinema.annotate(distance=models.Max(distation))
   return queryset
like image 702
Serg Bombermen Avatar asked May 03 '18 10:05

Serg Bombermen


1 Answers

You might need to add an output_field to your annotation:

queryset = get_cinema.annotate(distance=models.Max(distation, output_field=models.FloatField()))
like image 132
Ashish Acharya Avatar answered Nov 15 '22 19:11

Ashish Acharya