Django project optimization guide – Part 1
dizballanze.com
dizballanze.com
To add, if using Django Debug Toolbar, there is a line_profiler [1] extension for it: https://github.com/dmclain/django-debug-toolbar-line-profile...
I wanted to take a moment here and tell the HN community thanks for all the contributions/support the library has received to continue along. It can definitely use all the support it can get. Silk has so much potential but works as a free tool for many.
Previously I've hacked in printing out SQL statements, but the logging configuration is a lot nicer.
Common hot-spots I've noticed (other than n+1 queries) is deserialisation of database rows into Django ORM objects - it's relatively expensive, and template rendering. I'd definitely choose Jinja2 on a new project for templating as it's more generally more capable and approximately 2x faster, the downside being the goal of "logic-less templates" is slightly harder to achieve.
On the other hand, many django plugins are written to accommodate only django templates. By choosing jinja2, you will be severely limiting what plugins you can use.
Jinja2 is more like a superset of django templates with some minor syntax modifications.
So I would recommend you go with django templates and bring in jinja2 only if needed (which would be 0.001% of the time)
This is from experience where I went with Jinja2 for one project and learned my lesson. Now for the next one I just went with the default. Some of django template's choices are bit of an hindrance but an affordable price for the interoperability it provides.
We've been using Jinja2 at my startup since the beginning; in the four years I'be been working here I can't recall any issues with plug-ins using it.
So using non-django templates would rule out this kind of thing right?
Looking forward to Part 2!