Django Glossary

A complete glossary of Django terms and definitions designed to make learning Django simple and accessible. Explore key concepts, core features, and essential terminology all in one place.

1

Topic: Core & Project Structure


The Core & Project Structure terms explain how a Django project is organized and configured. These concepts cover files like manage.py, settings.py, and urls.py, along with project-level settings that control how your web application runs.


Django

Django is a high-level Python web framework that helps developers build secure, scalable, and maintainable web applications quickly. It includes built-in tools for authentication, database handling, and templates.

MTV Pattern

Django follows the Model-Template-View (MTV) pattern. Models handle data, Templates control presentation, and Views connect the two with business logic.

Project

A Django project is the main container for your entire web application. It includes settings, apps, and configurations needed to run the site.

App

A Django app is a modular component within a project that handles one specific feature, such as a blog, user system, or payment service.

manage.py

manage.py is a command-line utility for running Django tasks like starting the server, applying migrations, or creating apps.
python manage.py runserver

settings.py

settings.py is the configuration file for a Django project. It stores database settings, installed apps, middleware, templates, and other global settings.

urls.py

urls.py defines the URL patterns that connect web addresses to views. Each project can have a main urls.py and apps can include their own.
path('blog/', include('blog.urls'))

wsgi.py

wsgi.py is the entry point for deploying Django projects using WSGI servers like Gunicorn or uWSGI. It connects your project with web servers.

asgi.py

asgi.py is the entry point for deploying Django with ASGI servers like Daphne or Uvicorn. It supports async features such as WebSockets.

INSTALLED_APPS

INSTALLED_APPS is a list inside settings.py that tells Django which applications are active in the project.

SECRET_KEY

SECRET_KEY is a unique value in settings.py used for security, such as cryptographic signing. It must be kept private in production.

DEBUG

DEBUG is a setting that controls whether Django shows detailed error pages. It should be True in development and False in production.

ALLOWED_HOSTS

ALLOWED_HOSTS is a list of domain names or IP addresses where the Django project is allowed to run. It prevents HTTP Host header attacks.

Environment Variables

Environment variables store sensitive configuration like database passwords or API keys outside of the codebase. Django can read them using libraries like django-environ.

DJANGO_SETTINGS_MODULE

DJANGO_SETTINGS_MODULE is an environment variable that tells Django which settings file to use when running the project.

Model

A model in Django is a Python class that defines the structure of a database table. Each attribute of the model represents a database field.

Field

A field is an attribute in a Django model that represents a column in the database table. Each field type defines the kind of data stored.

CharField

CharField is used to store short text strings with a defined maximum length.
title = models.CharField(max_length=100)

TextField

TextField is used for storing long text content without a maximum length limit.

IntegerField

IntegerField is used to store whole numbers in the database.

BooleanField

BooleanField stores True or False values in the database.

FloatField

FloatField is used to store floating-point numbers (decimal values).

DateField

DateField is used to store date values (year, month, day).

DateTimeField

DateTimeField is used to store date and time information.

SlugField

SlugField stores short labels, often used in URLs for SEO-friendly links.

EmailField

EmailField is used to store email addresses with validation.

URLField

URLField stores web addresses and ensures they are valid URLs.

UUIDField

UUIDField is used to store universally unique identifiers (UUIDs).

AutoField

AutoField is an integer field that automatically increments, commonly used as the primary key.

ForeignKey

ForeignKey creates a many-to-one relationship between two models.

ManyToManyField

ManyToManyField creates a many-to-many relationship between two models.

OneToOneField

OneToOneField creates a one-to-one relationship between two models.

Primary Key

A primary key is a unique identifier for each record in a database table. Django automatically creates one if not defined.

Manager

A manager is the interface through which database operations are provided to Django models. The default manager is objects.

QuerySet

A QuerySet is a collection of objects retrieved from the database. It allows filtering, ordering, and chaining queries.

filter()

The filter() method is used to retrieve objects from the database that match given conditions.
Book.objects.filter(author='John')

get()

The get() method returns a single object that matches the query. If no match or multiple matches are found, it raises an error.
Book.objects.get(id=1)

exclude()

The exclude() method returns a QuerySet excluding objects that match certain conditions.

order_by()

The order_by() method arranges QuerySet results in ascending or descending order.

values()

The values() method returns dictionaries instead of model instances, useful for specific fields only.

annotate()

The annotate() method is used to add calculated values such as counts or sums to QuerySets.

aggregate()

The aggregate() method computes summary values like total, average, min, or max from a QuerySet.

Q Objects

Q objects are used for complex queries with OR, AND, or NOT conditions.

F Expressions

F expressions allow you to refer to model field values directly in queries without fetching them into Python.
3

Topic: Migrations


Migrations in Django are a way to apply and track changes you make to your models (database schema). They help keep your database in sync with your models without writing raw SQL.


Migrations

Migrations are Django’s system for handling database schema changes, such as creating tables or adding fields, in a structured and trackable way.

makemigrations

makemigrations is a Django management command that generates migration files based on changes in your models.
python manage.py makemigrations

migrate

migrate is a Django command that applies migration files to the database, creating or updating tables and fields.
python manage.py migrate

Migration Operations

Migration operations are instructions inside migration files that describe what changes to apply to the database, such as CreateModel or AddField.

Migration Squashing

Migration squashing is the process of combining multiple migration files into a single file to simplify and clean up the migration history.

inspectdb

inspectdb is a Django command that generates model code by inspecting an existing database, useful for working with legacy databases.
python manage.py inspectdb
4

Topic: Views & URL Routing


Views and URL Routing define how incoming web requests are handled and matched to the right logic and templates. These terms cover function-based views, class-based views, URL patterns, and reverse routing in Django 5.2.


View

A view is a Python function or class method that takes a web request and returns a web response.

Function-Based View (FBV)

FBVs are regular Python functions used as views, ideal for simple, direct handling of requests.

Class-Based View (CBV)

CBVs are classes that structure views using methods and inheritance, making complex patterns easier to reuse and maintain.

Generic Views

Generic views are built-in class-based views that handle common cases like displaying lists or detail pages with minimal code.

TemplateView

TemplateView renders a specified template. It's a simple generic view for static pages or basic templates.
path('', TemplateView.as_view(template_name='home.html'))

ListView

ListView displays a list of objects from a model in a template with built-in pagination support.

DetailView

DetailView shows detailed information for a single object, fetched by its primary key or slug.

FormView

FormView handles displaying and validating forms and deciding what to do when the form is submitted.

CreateView

CreateView simplifies the process of displaying a form for creating a new database object and saving it.

UpdateView

UpdateView displays a form to edit an existing object and saves changes when the form is submitted.

DeleteView

DeleteView provides a confirmation page and deletes an object when confirmed by the user.

Mixins

Mixins are reusable class components that add functionality like login checks or permission enforcement to class-based views.

LoginRequiredMixin

LoginRequiredMixin ensures that only authenticated users can access a class-based view.

URL Dispatcher

Django’s URL dispatcher maps URL patterns to view functions or classes using path() or re_path().

path()

path() is used to define URLs with a simplified syntax and parameter capturing.

re_path()

re_path() allows defining URLs using regular expressions for more complex patterns.

include()

include() lets you reference other URL configurations, keeping the project URL structure modular.

Namespaces

Namespaces allow you to group URL names to avoid collisions when multiple apps define similar URL names.

reverse()

reverse() returns the URL string corresponding to a view name, useful for dynamic URL lookup in code.

redirect()

redirect() returns an HTTP response to redirect the user to another URL, often used after form submissions.

Http404

Http404 is an exception raised in a view to indicate that a requested resource was not found, automatically returning a 404 page.
5

Topic: Requests & Responses


Requests and responses are at the core of Django’s request/response cycle. These terms explain how Django handles incoming HTTP requests and returns responses like HTML, JSON, or files.


HttpRequest

HttpRequest is an object that contains metadata about the incoming request, including method, headers, cookies, and user data.

HttpResponse

HttpResponse is the standard response class in Django that returns plain text, HTML, or other content to the client.
return HttpResponse("Hello, world!")

JsonResponse

JsonResponse is a subclass of HttpResponse that automatically serializes Python dictionaries into JSON format.
return JsonResponse({"status": "ok"})

StreamingHttpResponse

StreamingHttpResponse allows sending large responses in chunks instead of loading the entire content into memory.

QueryDict

QueryDict is a dictionary-like object used to handle GET and POST parameters, supporting multiple values for the same key.

request.GET

request.GET is a QueryDict that holds all query parameters sent in the URL.

request.POST

request.POST is a QueryDict that holds data submitted through an HTML form using the POST method.

request.FILES

request.FILES is a dictionary-like object containing uploaded files, accessible when a form includes file fields.

request.user

request.user represents the currently logged-in user. If no user is authenticated, it defaults to AnonymousUser.

request.session

request.session is a dictionary-like object for storing per-user data across requests using Django’s session framework.
6

Topic: Templates


Templates in Django define how data is presented to users, usually in the form of HTML pages. They use the Django Template Language (DTL) to mix static HTML with dynamic content.


Template

A template is an HTML file that defines the structure of a web page, with placeholders for dynamic content.

Django Template Language (DTL)

DTL is Django’s built-in language for adding dynamic content in templates. It includes variables, tags, filters, and control structures.

Template Inheritance

Template inheritance allows you to create a base template and extend it in child templates to reuse common layout elements.

Template Tags

Template tags are special keywords inside {% %} that perform logic in templates, such as loops, conditions, and including other files.

Template Filters

Template filters are used to modify variables in templates, such as formatting dates, capitalizing text, or truncating strings.
{{ name|upper }}

Context

The context is a dictionary of data passed from a view to a template, making variables available inside the template.

Context Processors

Context processors are functions that add extra variables (like request or user) to all templates automatically.

include tag

The include tag inserts another template inside the current template, useful for reusable components like headers or footers.
{% include 'navbar.html' %}

url tag

The url tag generates URLs dynamically using view names instead of hardcoding paths.
{% url 'blog:detail' post.id %}

static tag

The static tag generates URLs for serving static files like CSS, JavaScript, and images.
<img src="{% static 'images/logo.png' %}">
7

Topic: Static & Media


Django separates static files (CSS, JavaScript, images) from media files (user uploads). These terms explain how to configure and serve them correctly in development and production.


Static Files

Static files are assets like CSS, JavaScript, and images that don’t change per request. They are stored in static/ directories within apps or a global static folder.

STATIC_URL

STATIC_URL is the URL prefix used to serve static files to the browser.
STATIC_URL = '/static/'

STATIC_ROOT

STATIC_ROOT is the directory where Django collects all static files when you run collectstatic, usually for production deployment.

collectstatic

collectstatic is a management command that gathers static files from all apps into STATIC_ROOT for deployment.
python manage.py collectstatic

Media Files

Media files are user-uploaded files such as profile pictures, documents, or attachments. They are stored separately from static files.

MEDIA_URL

MEDIA_URL is the URL prefix used to serve user-uploaded files to the browser.
MEDIA_URL = '/media/'

MEDIA_ROOT

MEDIA_ROOT is the absolute filesystem path where uploaded media files are stored.

FileField

FileField is a model field used to upload and store files in MEDIA_ROOT.

ImageField

ImageField is a model field that uploads image files, with validation to ensure only valid image formats are accepted.

Storage Backends

Storage backends define how files are stored and retrieved, with options like the local filesystem, Amazon S3, or other cloud services.
8

Topic: Forms & Validation


Django provides a powerful forms library that handles HTML form rendering, validation, and saving data to models. These terms explain how forms work and how to ensure data is valid before saving.


Form

A Form in Django is a Python class that defines fields, handles input validation, and renders HTML form elements.

ModelForm

ModelForm is a special form class that is automatically built from a Django model, making it easy to create and update model instances.

Form Fields

Form fields define the type of input users can provide, such as text, email, password, or file uploads.

Widgets

Widgets control how form fields are rendered in HTML, such as using text inputs, dropdowns, or checkboxes.

is_valid()

The is_valid() method checks if submitted form data passes all validation rules and returns True or False.

cleaned_data

cleaned_data is a dictionary containing validated form data after calling is_valid().

validators

Validators are functions or classes that check whether a field’s value meets certain rules, such as email format or value ranges.

ValidationError

ValidationError is an exception raised when data fails validation, showing error messages in the form.

form.save()

The save() method on ModelForm creates or updates a model instance using validated form data.

csrf_token

csrf_token is a template tag that inserts a hidden security token in forms to protect against Cross-Site Request Forgery attacks.
{% csrf_token %}
9

Topic: Auth, Permissions & Security


Django includes a built-in authentication and authorization system that handles users, groups, and permissions. It also provides middleware and settings to secure applications against common web vulnerabilities.


Authentication

Authentication is the process of verifying a user’s identity, usually through a username and password.

Authorization

Authorization determines what an authenticated user is allowed to do, based on permissions or group memberships.

User Model

The User model is Django’s built-in model for managing user accounts, including usernames, passwords, and permissions.

AbstractUser

AbstractUser is a base class you can extend to add extra fields while keeping Django’s default authentication features.

AbstractBaseUser

AbstractBaseUser is a more flexible base class that allows building a fully custom user model from scratch.

Custom User Model

A custom user model replaces Django’s default User model to fit project-specific requirements, such as using email instead of username.

Permissions

Permissions are rules that define whether a user can perform certain actions like adding, editing, or deleting objects.

Groups

Groups are collections of permissions that can be applied to multiple users at once for easier management.

Authentication Backends

Authentication backends are classes that define how Django checks user credentials, allowing integration with custom systems.

Password Hashers

Password hashers securely store user passwords using hashing algorithms like PBKDF2 or Argon2.

Password Validators

Password validators enforce rules like minimum length, character complexity, or avoiding common passwords.

Sessions

Sessions store data on a per-user basis across requests, often used for keeping users logged in.

CSRF Protection

Cross-Site Request Forgery (CSRF) protection ensures that forms are submitted intentionally by including a hidden token in requests.

SecurityMiddleware

SecurityMiddleware adds HTTP headers to improve security, such as enforcing HTTPS and preventing content sniffing.

XSS Protection

Django escapes variables in templates by default, helping prevent Cross-Site Scripting (XSS) attacks.

Clickjacking Protection

Clickjacking protection is enabled with the X-Frame-Options header, preventing your site from being embedded in iframes.

X_FRAME_OPTIONS

X_FRAME_OPTIONS is a Django setting that controls whether your site can be displayed in an iframe.

SECURE_SSL_REDIRECT

SECURE_SSL_REDIRECT is a setting that forces all requests to use HTTPS instead of HTTP.

HSTS (SECURE_HSTS_SECONDS)

HTTP Strict Transport Security (HSTS) tells browsers to always use HTTPS for your site for a defined period of time.
10

Topic: Admin


Django comes with a powerful built-in admin interface for managing application data. These terms explain how to customize and extend the admin site for your project.


Django Admin

The Django Admin is an automatically generated web interface for managing models and data in your project.

ModelAdmin

ModelAdmin is a class used to define how a model is displayed and managed inside the Django Admin site.

admin.register

The admin.register decorator is used to register a model with the Django Admin site.

list_display

list_display defines which model fields are shown as columns in the admin list view.

search_fields

search_fields allows adding a search box in the admin to search model records by specific fields.

list_filter

list_filter adds sidebar filters in the admin list view, letting you filter records by field values.

readonly_fields

readonly_fields makes specific fields non-editable in the admin form view.

Inlines

Inlines allow related models to be edited on the same page as the parent model in the admin. Common types are TabularInline and StackedInline.

Admin Actions

Admin actions are custom functions you can define to perform bulk operations on selected records in the admin list view.

Admin Site Customization

The admin site can be customized with branding, themes, custom templates, and additional features to match project needs.
11

Topic: Caching


Django includes a caching framework to improve performance by storing frequently accessed data. These terms explain how to use different cache backends and caching techniques in Django 5.2.


Caching Framework

The Django caching framework provides tools to store and retrieve data quickly, reducing database queries and speeding up page loads.

Cache Backends

Django supports multiple cache backends such as local memory, file-based, Memcached, and Redis for storing cached data.

Per-site Cache

Per-site cache stores the entire output of every page for all users, useful for sites where content changes rarely.

Per-view Cache

Per-view cache stores the output of specific views so the same response can be quickly served on repeated requests.

Template Fragment Cache

Template fragment caching allows caching only a portion of a template, such as a sidebar or navigation menu.

cache_page decorator

The cache_page decorator is applied to views to cache their output for a specified duration.
@cache_page(60 * 15)
def my_view(request): ...

Low-level Cache API

The low-level cache API provides direct access to cache operations like get(), set(), add(), and delete().

Cache Keys

Cache keys are unique identifiers used to store and retrieve cached data from the backend.

Cache Invalidation

Cache invalidation ensures outdated or changed data is removed from the cache so fresh data is served.
12

Topic: Internationalization & Time


Django has built-in support for internationalization (i18n), localization (l10n), and timezone handling. These terms explain how to translate content and work with dates and times correctly.


i18n (Internationalization)

Internationalization is the process of preparing a Django project for translation into different languages.

l10n (Localization)

Localization adapts an application’s content to a specific language, region, or culture, including formats for dates, times, and numbers.

Timezone Support

Django provides timezone-aware datetimes, allowing applications to handle users in different regions consistently.

USE_TZ

USE_TZ is a Django setting that enables timezone-aware datetimes. It should be True for modern projects.

LocaleMiddleware

LocaleMiddleware automatically detects the user’s language preference from the request and serves the correct translation.

gettext

gettext is a function used to mark strings in Django code for translation.

gettext_lazy

gettext_lazy is used for marking strings for translation in places where the translation should be delayed until runtime.

Format Localization

Format localization automatically displays dates, numbers, and currencies in formats appropriate to the user’s locale.

Language Switching

Language switching allows users to change the site’s language, often using Django’s built-in set_language view.
13

Topic: Signals


Signals in Django allow different parts of an application to communicate with each other. They help trigger actions automatically when certain events occur, such as saving or deleting a model instance.


Signals

Signals are Django’s messaging system that let you run custom code when specific events happen in the framework.

pre_save

The pre_save signal is sent just before a model instance is saved to the database.

post_save

The post_save signal is sent immediately after a model instance is saved, useful for creating related objects or sending notifications.

pre_delete

The pre_delete signal is sent just before a model instance is deleted from the database.

post_delete

The post_delete signal is sent after a model instance is deleted, often used for cleanup tasks like removing files.

m2m_changed

The m2m_changed signal is triggered when a many-to-many relationship is modified, such as adding or removing related objects.

receiver decorator

The receiver decorator is used to connect a function to a signal in a clean and reusable way.

dispatch_uid

dispatch_uid is an optional identifier that prevents the same signal handler from being registered more than once.
14

Topic: Management & CLI


Django includes a set of management commands to handle tasks like running the server, managing the database, and creating apps. These terms explain the most commonly used commands in Django 5.2.


startproject

startproject is a Django command that creates a new project directory with the necessary files to begin development.
django-admin startproject mysite

startapp

startapp creates a new Django app inside a project with its own models, views, and other components.
python manage.py startapp blog

runserver

runserver starts Django’s development web server to test the application locally.
python manage.py runserver

createsuperuser

createsuperuser is a command to create an admin user who can log into the Django admin site.
python manage.py createsuperuser

shell

shell opens an interactive Python shell with Django preloaded, allowing direct interaction with models and queries.

check

check runs system checks to identify potential configuration or code issues in a Django project.

showmigrations

showmigrations lists all available migrations and their current status (applied or unapplied).

dumpdata

dumpdata outputs data from the database into a JSON fixture, which can be reloaded later.

loaddata

loaddata loads data from fixture files (such as JSON or YAML) into the database.

Custom Management Commands

Custom management commands let developers create their own commands by adding scripts to the management/commands directory inside an app.
15

Topic: Testing


Django provides a built-in testing framework based on Python’s unittest module. These terms explain how to write and run tests for your Django applications.


Test Runner

The test runner is the system Django uses to discover and run tests across apps in a project.

TestCase

TestCase is the most common class for writing tests in Django. It sets up a test database and provides helper methods for assertions.

SimpleTestCase

SimpleTestCase is used for tests that don’t require a database, such as testing utilities or views without models.

TransactionTestCase

TransactionTestCase allows testing code that requires real database transactions and can reset the database to a clean state.

LiveServerTestCase

LiveServerTestCase starts a live Django server in the background for end-to-end or browser-based testing.

Client

The test Client simulates a web browser, letting you send GET and POST requests to views and check responses.
response = self.client.get('/home/')

RequestFactory

RequestFactory allows creating request objects for testing views in isolation without running the whole middleware stack.

Fixtures

Fixtures are serialized data files (JSON, YAML, or XML) that load predefined data into the test database.

setUp / tearDown

setUp and tearDown are methods that run before and after each test to prepare test data or clean up resources.

assertContains

assertContains is a helper method that checks whether a response contains certain text, with optional status code validation.
16

Topic: Framework Utilities & Apps


Django includes several built-in frameworks and utilities that extend its functionality. These terms explain optional apps and helpers commonly used in Django projects.


Sites Framework

The Sites framework lets you manage multiple websites from a single Django project by storing site-specific data like domain names.

ContentTypes Framework

The ContentTypes framework provides a generic way to link models together by storing model references as database records.

GenericForeignKey

GenericForeignKey allows creating relationships to any model using the ContentTypes framework, instead of being tied to a specific model.

Flatpages

The Flatpages app allows storing and serving simple static pages (like About or Terms) from the database without coding new views.

Redirects App

The Redirects app manages URL redirects in the database, useful for handling moved or outdated pages.

Sitemaps Framework

The Sitemaps framework automatically generates XML sitemaps that help search engines index your site.

Syndication Feeds

The Syndication framework makes it easy to create RSS or Atom feeds for your Django site.

Humanize

The Humanize app provides template filters that display numbers and dates in a more human-friendly format.

Pagination (Paginator)

Paginator is a utility class that divides query results or lists into multiple pages, often used in list views.

Messages Framework

The messages framework provides a simple way to send feedback to users, such as success or error notifications, across requests.
Never miss a story on Django.wiki

Subscribe for fresh tutorials, snippets, and updates.

By subscribing you agree to our Privacy Policy.