djangodocs.org

766 sections in Django dev Search all versions →

2029

Internals Django Deprecation Timeline

Calling QuerySet.aiterator() after prefetch_related() without providing a chunk_size will raise ValueError. The Extract and Trunc database functions will capture the current timezone in migrations when the tzinfo argument is omitted and USE_TZ is True.

ListView

Reference Generic display views

classdjango.views.generic.list.ListView : A page representing a list of objects. classdjango.views.generic.list.BaseListView : A base view for displaying a list of objects.

DateMixin

Reference Date-based mixins

classDateMixin[source] : A mixin class providing common behavior for all date-based views.

SingleObjectMixin

Reference Single object mixins

classdjango.views.generic.detail.SingleObjectMixin : Provides a mechanism for looking up an object associated with the current HTTP request.

Reference Admin actions Advanced action techniques

Actions may limit their availability to users with specific permissions by wrapping the action function with the action() decorator and passing the permissions argument: The make_published() action will only be available to users that pass the ModelAdmin.has_change_permission() check when it …

Using a SimpleListFilter

Reference ModelAdmin List Filters

… own list filter by subclassing django.contrib.admin.SimpleListFilter. You need to provide the title and parameter_name attributes, and override the lookups and queryset methods, e.g.: NOTE: As a convenience, the HttpRequest object is passed to the lookups > and queryset methods, for …

GeometryDistance

Reference Geographic Database Functions Measurements

classGeometryDistance(expr1,expr2,**extra)[source] Availability: PostGIS Accepts two geographic fields or expressions and returns the distance between them. When used in an order_by() clause, it provides index-assisted nearest-neighbor result sets.

Shortcuts

Reference The sitemap framework

The sitemap framework provides a convenience class for a common case: classGenericSitemap(info_dict,priority=None,changefreq=None,protocol=None)[source] : The django.contrib.sitemaps.GenericSitemap class allows you to create a sitemap by passing it a dictionary which has to contain at least a queryset entry.

ObjectDoesNotExist

Reference Django Exceptions Django Core Exceptions

exceptionObjectDoesNotExist[source] : The base class for Model.DoesNotExist exceptions. A try/except for ObjectDoesNotExist will catch DoesNotExist exceptions for all models.

MultipleObjectsReturned

Reference Django Exceptions Django Core Exceptions

exceptionMultipleObjectsReturned[source] : The base class for Model.MultipleObjectsReturned exceptions. A try/except for MultipleObjectsReturned will catch MultipleObjectsReturned exceptions for all models.

Reference Form fields

Two fields are available for representing relationships between models: ModelChoiceField and ModelMultipleChoiceField. Both of these fields require a single queryset parameter that is used to create the choices for the field.

ModelChoiceField

Reference Form fields Fields which handle relationships

classModelChoiceField(**kwargs)[source] : - Default widget: Select - Empty value: None - Normalizes to: A model instance. - Validates that the given id exists in the queryset. - Error message keys: required, invalid_choice

ModelMultipleChoiceField

Reference Form fields Fields which handle relationships

classModelMultipleChoiceField(**kwargs)[source] : - Default widget: SelectMultiple - Empty value: An empty QuerySet (self.queryset.none()) - Normalizes to: A QuerySet of model instances. - Validates that every id in the given list of values exists in the queryset.

ModelChoiceIterator

Reference Form fields Fields which handle relationshipsIterating relationship choices

classModelChoiceIterator(field)[source] : The default class assigned to the iterator attribute of ModelChoiceField and ModelMultipleChoiceField. An iterable that yields 2-tuple choices from the queryset.

ModelChoiceIteratorValue

Reference Form fields Fields which handle relationshipsIterating relationship choices

classModelChoiceIteratorValue(value,instance)[source] : Two arguments are required:

DoesNotExist

Reference Model class reference Attributes

exceptionModel.DoesNotExist : This exception is raised by the ORM when an expected object is not found. For example, QuerySet.get() will raise it when no object is found for the given lookups.

When

Reference Conditional Expressions The conditional expression classes

classWhen(condition=None,then=None,**lookups)[source] A When() object is used to encapsulate a condition and its result for use in the conditional expression. Using a When() object is similar to using the filter() method.