← Back to Django Course | Chapter 1: Django Fundamentals & Setup | Lesson 2 of 9

Why Use Django?

Django saves you time by giving you tools that many other websites already need, like login pages and admin dashboards.

Batteries-Included Philosophy

Django ships with an ORM, authentication, an admin site, and a templating engine out of the box, so you do not need to hunt for and glue together separate libraries.

Example: Batteries-Included Philosophy

These five apps ship enabled in every new project — admin, auth, sessions, messages, and static file handling — all included without installing anything extra.

markup
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]
{# Django-only code -- models.py/views.py/urls.py/settings.py snippets, or template markup using Django template tags/variables -- can't run standalone via Judge0 or the browser preview, since it needs a real Django project. Only this course's pure-Python examples (example_lang == 'python', no Django imports) are actually runnable, so those still get the button below. #}

Security Out of the Box

Django automatically protects against common attacks like Cross-Site Request Forgery (CSRF) and SQL injection, so you get a safer app by default without extra setup.

Note: Security features are enabled automatically, not opt-in, so new projects start safe.

Example: Security Out of the Box

{% csrf_token %} is the only line you add — Django rejects any POST request missing this token, blocking CSRF attacks automatically.

markup
<form method="post">
  {% csrf_token %}
  <input type="text" name="comment">
  <button type="submit">Post</button>
</form>
{# Django-only code -- models.py/views.py/urls.py/settings.py snippets, or template markup using Django template tags/variables -- can't run standalone via Judge0 or the browser preview, since it needs a real Django project. Only this course's pure-Python examples (example_lang == 'python', no Django imports) are actually runnable, so those still get the button below. #}

Faster Development Speed

Because so much is pre-built, a working Django site can go from an empty folder to a working page much faster than writing every piece by hand.

Example: Faster Development Speed

Two lines give the Article model a complete add/edit/delete/search admin interface — no HTML, forms, or views written by hand.

markup
from django.contrib import admin
from .models import Article

admin.site.register(Article)
{# Django-only code -- models.py/views.py/urls.py/settings.py snippets, or template markup using Django template tags/variables -- can't run standalone via Judge0 or the browser preview, since it needs a real Django project. Only this course's pure-Python examples (example_lang == 'python', no Django imports) are actually runnable, so those still get the button below. #}

Django Scales With Your Project

Django works equally well for a two-page hobby site and a large production system, because its structure keeps growing code organized as more features are added.

Warning: Skipping structure early on a "small" project often causes pain once it grows.

Example: Django Scales With Your Project

Each new feature becomes its own app added to this one list — the same INSTALLED_APPS pattern scales from a single hobby app to dozens of apps in a large project.

markup
INSTALLED_APPS = [
    'django.contrib.admin',
    'blog',
    'shop',
    'accounts',
]
{# Django-only code -- models.py/views.py/urls.py/settings.py snippets, or template markup using Django template tags/variables -- can't run standalone via Judge0 or the browser preview, since it needs a real Django project. Only this course's pure-Python examples (example_lang == 'python', no Django imports) are actually runnable, so those still get the button below. #}
Common Mistakes
  1. Thinking Django is only good for huge sites and overkill for small projects.
  2. Ignoring Django's built-in admin panel and rebuilding one from scratch instead.
  3. Believing Django forces one specific frontend technology instead of working with any frontend.
Chapter Summary
  • Django speeds up development with reusable, built-in components.
  • It comes with a free admin interface generated from your models.
  • Django has strong security defaults like CSRF and SQL-injection protection.
  • It scales from small hobby projects to large production sites.

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.