4 ms·
Because doing something as simple as `select sum(length(content)) from app_comment;` in Django ORM is not possible.
by lcnmrn 11y ago
Because doing something as simple as `select sum(length(content)) from app_comment;` in Django ORM is not possible.
- collyw 11y agoYou can still use SQL from the Django ORM.
- Beltiras 11y agoExactly, using .raw
- andor 11y agoIt's possible with the ORM, but much more complicated than the SQL you intend to get: AppComment.objects.annotate(content_len=Length('content')).all().aggregate(Sum('content_len')) https://docs.djangoproject.com/en/1.9/ref/models/expressions/ https://docs.djangoproject.com/en/1.9/ref/models/expressions...