I use a Django comment structure that uses shared foreign keys.
Question: How can I sort a given sample request by their comment account using a common foreign key search?
Reading the django docs on the topic , he says that you need to compute them without using the aggregation API:
The Django Database Aggregation API does not work with GenericRelation. [...] For now, if you need aggregates in general terms, you will need to compute them without using the aggregation API.
The only way I can think of is to iterate over my query, generate a list with content_typeand object_idfor each item, and then run a second set of queries to filter the Comment model with that list content_typeand object_id... sort the objects by account and then re-create a new request in that order, pulling content_objectfor each comment ...
It just seems wrong, and I'm not even sure how to do it.
Ideas? Someone must have done this before.
I found this post on the Internet, but for this I need SQL handwriting - is it really necessary?
source
share