I am using django to build an app that is slightly heavy on functionality. Consequently my templates are a bit heavy (nested loops, if conditions etc). I am noticing that 70% to 80% of time is spent in render_to_response step of my views.
I haven’t found anything indicating performance issues around template engine in django on google. Anyone here faced similar issues / any suggestions to solve this problem?
I am using django to build an app that is slightly heavy on functionality.
Share
One thing to keep in mind is that QuerySet objects are lazy. They won’t actually hit the database until you a perform an operation that requires the query to be executed (looping, counting, etc).
If you pass a QuerySet object in your template context, often a loop (or some other operation) inside your template will be what triggers the database call. When this happens, the template rendering is “penalized” for the database I/O, but the overall response time should be unaffected by whether it happens in the view or in the template rendering.