PyCon, the gathering for the community using and developing the open-source Python programming language. This is the second year of the PyCon Pune where the community will meet for two days of talks and working on upstream projects in two days of dev sprint. CFP ends on 15th September AoE.


Note to submitters: The talks will be selected by a team. We will not count the public votes.

Hosted by

PyCon Pune 2017 more

Sanyam Khurana


Profiling and optimizing Django applications

Submitted Sep 9, 2017

Many amateur developers who picks up Django write code which seems to work, but fails at scale.

Django has been made as a The web framework for perfectionists with deadlines, and perfection is often forgotten due to deadlines. In this talk, we’ll discuss about common pitfalls to avoid while working on a Django based web application. Often times we don’t care about what the ORM queries are costing us and if they could be written in a better way.

In the end we’ll look at an overall architecture of entire Django web application including wsgi, nginx, caching and database layer. This would provide a starting point to write clean code and optimizing Django Applications to the audience


  • Profiling our web application to know exactly what queries are being executed on the database.
  • Making optimal use of Django ORM to avoid multiple queries to the database.
  • Usage of F objects, Q objects, prefetch_related, select_related et. all.
  • Addressing n+1 queries problems to database with ORM.
  • Making use of Asynchronous requests to avoid creating a backlog for the request-response cycle. A little bit about task queues like Celery.
  • Caching: Different types of caches to use -- both django caching as well as something like in-memory Redis cache.


  • Hands-on experience with developing Django Applications
  • Basic understanding of Django ORM including usage of Querysets and Managers.

Speaker bio

Sanyam is an Open Source Contributor from Delhi, India. Mostly goes by CuriousLearner all over the web. He contributes to various upstream projects in different organizations & maintains a few of them. He has contributed various patches and bug reports upstream to Gecko Engine from Mozilla Organization.

Recently he is getting his hands dirty with CPython codebase.

He is a vouched Mozillian & an official Representative of Mozilla and has been listed in AUTHORS as well as credits section of every browser ever released by Mozilla. He mentored for PyDSA in RGSoC 2017. He volunteers for PyCon India and PyDelhiConf and has been an active member of PyDelhi, ILUG-D, LinuxChixIndia and DGPLUG.



{{ gettext('Login to leave a comment') }}

{{ gettext('Post a comment…') }}
{{ gettext('New comment') }}
{{ formTitle }}

{{ errorMsg }}

{{ gettext('No comments posted yet') }}

Hosted by

PyCon Pune 2017 more