Module 11 of 12

Security & Performance

Lessons

About This Module

Before a Django application meets real users, it has to be both safe and fast. Django protects you against many common attacks by default, but those protections only work if you understand what they do and avoid switching them off, and a page that is correct but slow will still frustrate the people using it.

In this module you will learn how attacks such as SQL injection and cross-site scripting (XSS) work and how Django's ORM and template escaping defend against them. You will then learn how to find and fix slow database access, including the N+1 query problem, using select_related() and prefetch_related() together with the Django Debug Toolbar.

Watch the lessons in order, then continue on to Deployment & Production. Some of these videos were recorded on older Django releases, so check the official documentation if a detail differs on your install.

Lessons

4 videos
01

Django Security - SQL Injection (With Arun Ravindran)

Part of a Django security series that explains what SQL injection is, how it works, and the protections Django has in place against it.

02

Django Cross-Site Scripting (XSS)

Demonstrates common ways cross-site scripting shows up in a Django application and how to fix those flaws.

03

Django Query Optimization / select_related & prefetch_related / django-debug-toolbar / N+1 Problem

Explains query optimization and solving the N+1 problem with select_related() and prefetch_related(), using the Django Debug Toolbar to see the effect.

04

Optimize Your Django Queries with select_related, prefetch_related and Django Debug Toolbar

A simple introduction to optimizing Django queries with select_related and prefetch_related.