Closed rberiot closed 8 years ago
+1 I am trying to do the same. I will use this workaround.
I needed to change otehr things in order to work with annotate and Count with datetime fields
As an alternate/potential fix - inspect the aggregation functions and extra field names. Not perfect but at least avoids the pokemon exception. https://github.com/pgollakota/django-chartit/pull/15
rberiot Thank you very much for this tip!
It seems using QuerySet.annotate() breaks chartit. the problem lies at validation.py:30 where it validates that the fields used are part of the model. meta.get_all_field_names() doesn't return annotated fields, for instance a Count() or an Avg() which are very useful in the case of a chart. here's the offending code:
as a temporary fix I changed it to this but it's just a dirty workarround and effectively breaks the validation: