KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
When I render a moderately complex dictionary (4 levels deep, ~2K data points) using django 1.4's default template system the template rendering step takes over 2800ms. When I do html-gen directly from python instead it takes ~80ms. Even using another template library ( jinja2 ) renders the same data (in fact, almost exactly the same template syntax - as jinja2 is nearly a drop-in replacement) in under 300ms. Interestingly, you don't even have to actually render the dictionary in the template to cause this performance issue in django's template system... all you have to do is pass it as an available variable to a template. A friend of mine suggested this may mean the system is, "...doing a defensive copy or (more stupidly) a comprehension [which] will take time due to running constructors" Anyone know why django's default template system takes so long to render dictionaries? * I'll work on adding requested details below * I am running in debug mode and have the DebugToolbarMiddleware set as one of my middleware classes. My settings.py file includes: TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + ( 'django.core.context_processors.request', ) and.... # rendering like this return render( request, template_name='ltm/search_results.html', context_instance=RequestContext(request, { 'menus': menus, 'results': result_dict }) )
Tags (comma-separated)
Save Edits
Cancel