[Django]-Django – queryset with extra method returns empty, count() says otherwise

1👍

I think I have just figured out the problem. Thanks go to Alex, whose comment has sparked the idea:

The PortfolioItem model has the properties current_value and current_gain, which I have been trying to replace with calculated SQL fields. It was my mistake to name one of the extra() method’s select fields ‘current_value’ without removing the property, as that led to the model having two fields with the same name. When I did away with that overlapping, everything became OK. Lesson is learned.

👤shanyu

Leave a comment