On 21 April 2016 at 10:06, <john.rg....@gmail.com> wrote: > Either way - we recently hit another Django limitation - as best I've been > able to tell, joining a table with itself seems to be very poorly supported > - so we're heading towards SqlAlchemy, and probably away from Django > altogether in time.
If you're building some report-like queries, or any static queries, I would suggest to use raw sql. You can optionally wrap results with model instances using Model.objects.raw(). Previously I used SQLAlchemy together with Django, but currently I'm moving from SA to templated raw queries, because building them using any ORM is too hard to maintenance (code is very unreadable in opposite to plain SQL). But embedding raw queries in Python code is generally bad, same as mixing Python together html (spaghetti code). That's why I'm working on SQL templating module based on Django` template engine. If you're interested please look at https://github.com/marcinn/django-sqltemplate/ (please note that is a alpha version, which may be unstable and API may be chaged). The main advantages of raw SQL are readability and no limits. Templated SQL gives you possibility to modify queries based on context variables, which is not flexible as querysets, but often good enough to do job well. But as a disadvantage you have to pay attention to SQL syntax and variables escaping. Kind Regards, Marcin -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAB2m7Cx%3D2AXJHGGLSt%2B1fhNPoJRJ2rKLdWnsW4uD0gZR4fJP%2BA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.