Open sourceActive

Django

High-level Python web framework whose QuerySet API provides lazy, chainable database queries.

Open source page ↗

Field note

What it does

Django's QuerySet API reference documents lazy evaluation, filtering, aggregation, field lookups, and query-related tools like Q and Prefetch objects.

Capabilities

Available capabilities

Tags

Tags

Ways to use it

Ways to use it

pypi

Python / Django

sdk

Python / Django

sdk

Python / Django

sdk

python / Django

pypi

Python / Django

pypi

python / Django

Product features

Product features

AddField

Adds a field to a model with optional preserve_default.

Admin site

Automated admin interface, one of Django's most popular features.

aggregate()

Returns a dictionary of aggregate values over the QuerySet.

AlterIndexTogether ¶

AlterModelManagers ¶

AlterModelOptions ¶

AlterModelTable ¶

AlterModelTableComment ¶

AlterOrderWithRespectTo ¶

AlterUniqueTogether ¶

errors.as_json()

Returns errors serialized as JSON.

as_view() classmethod

Deploys a class-based view into a URL pattern, assigning arguments onto the request instance.

Bound and unbound forms

A Form instance is either bound to a set of data or unbound.

Built-in tags and filters

Built-in libraries can be used without the load tag.

Bulk methods

Create, update, insert, and remove objects in bulk to reduce query counts.

Class-based views

Built-in display and editing views using mixins.

Class-based views mixins

Simple, single object, multiple object, editing and date-based mixins extend base views.

Comparison and conversion functions

Cast, Coalesce, Collate, Greatest, Least, NullIf.

Context objects

Populates and renders a context, optionally with a request via RequestContext.

CreateModel

Creates a new model in project history and a matching database table.

Date functions

Extract, Now, Trunc.

DefaultStorage

Provides lazy access to the default storage system defined by the default key in STORAGES.

QuerySet.defer() and only()

Avoid retrieving fields you don't need from the database.

DeleteModel

Deletes the model from project history and its table from the database.

Deprecation warnings

Deprecated methods remain in the API for at least two feature releases and issue warnings when called.

Engine class

Configures dirs, loaders, context processors, autoescape, and other template options.

errors

Dictionary of error messages keyed by field name.

File uploads

File objects, storage API, managing files, and custom storage.

FileSystemStorage

Implements basic file storage on a local filesystem, inheriting from Storage.

filter()

Returns a new QuerySet containing objects that match the given lookup parameters.

Generic date views

ArchiveIndexView, YearArchiveView, MonthArchiveView, WeekArchiveView, DayArchiveView, TodayArchiveView and DateDetailView.

Generic display views

DetailView and ListView for displaying object details and lists.

Generic editing views

FormView, CreateView, UpdateView and DeleteView for editing data.

Geographic framework

Geographic framework for building GIS web applications.

get_alternative_name()

get_valid_name()

Returns a filename suitable for the underlying storage system.

Internationalization and localization

InMemoryStorage

Memory-based file storage with no persistence, useful for speeding up tests.

Internal API marking

Objects prefixed with a leading underscore are internal APIs that may change.

is_valid()

Runs validation on a bound form and returns a boolean.

QuerySet.iterator()

Reduces memory usage when working with a large number of objects.

JSON functions

JSONArray, JSONObject.

Math functions

Abs, ACos, ASin, ATan, ATan2, Ceil, Cos, Cot, Degrees, Exp, Floor, Ln, Log, Mod, Pi, Power, Radians, Random, Round, Sign, Sin, Sqrt, Tan.

Middleware

Built-in middleware classes for request/response processing.

Migration Operations ¶

Migrations

Introduction to Migrations and schema operations.

_open() method

Required method called by Storage.open() to open files.

Prefetch() objects

Allows customizing prefetch_related() operations.

prefetch_related()

Returns a QuerySet that fetches related objects in a separate batch query.

Backwards-compatible aliases

Public APIs will not be moved or renamed without providing backwards-compatible aliases.

Q() objects

Encapsulates keyword arguments for complex, reusable query conditions.

QuerySet API

QuerySet method reference for making queries.

QuerySet.explain()

Provides detailed information about how the database executes a query, including indexes and joins used.

RawSQL and raw SQL

Allows explicit SQL to be added to a query when the ORM is not powerful enough.

RemoveField

Removes a field from a model.

RenameField

Renames a field on a model.

RenameModel ¶

RunPython

Special operation for running Python data migrations.

RunSQL

Special operation for manual SQL database manipulation.

_save() method

Called by Storage.save() to save file content.

Schema Operations ¶

select_related()

Returns a QuerySet that follows foreign-key relationships, selecting related object data.

select_related() and prefetch_related()

Retrieve related objects efficiently by reducing the number of database queries.

SeparateDatabaseAndState

Special operation separating database and state changes.

Storage class

Standardized API for storing files with default behaviors that backends inherit or override.

Storage subclass

Custom storage systems must subclass django.core.files.storage.Storage.

storages registry

Dictionary-like object retrieving a storage instance by alias defined in STORAGES.

Template loaders

Loader classes import templates from filesystem, app directories, or custom sources.

Testing

Writing and running tests with included testing tools.

Testing tools

Introduction, writing and running tests, and included testing tools.

Text functions

Chr, Concat, Left, Length, Lower, LPad, LTrim, MD5, Ord, Repeat, Replace, Reverse, Right, RPad, RTrim, SHA1/SHA224/SHA256/SHA384/SHA512, StrIndex, Substr, Trim, Upper.

UUID functions

UUID4, UUID7.

Window functions

CumeDist, DenseRank, FirstValue, Lag, LastValue, Lead, NthValue, Ntile, PercentRank, Rank, RowNumber.