0👍
✅
My solution eventually was to switch to SqlAlchemy
for complex queries. This package worked for me well – Aldjemy
2👍
Have you tried Raw SQL?
query = Statistics.objects.values('time').filter(game_id=1).\
annotate(users_sum=Sum('users', distinct=True)).\
annotate(timestamp=DateDiffHoursFunc(Value(datetime(2016, 05, 26)), F('time'))).\
values('users_sum', 'timestamp').query
query.group_by = ['time']
objs = QuerySet(query=query, models=Statistics)
Its a bit risky solution, but try it.
👤Dan
- [Answered ]-Select related of selected related
- [Answered ]-Django – TDD: 'HttpRequest' has no attribute 'POST'
- [Answered ]-How to access pk in views (Django)
- [Answered ]-Don't fail if log files are unavailable
- [Answered ]-How to properly add template tags to a django project
Source:stackexchange.com