djangodocs.org

743 sections in Django 6.0 Search all versions →

WeekArchiveView

Reference Class-based generic views - flattened index Date-based views

Methods as_view() dispatch() get() get_context_data() get_date_list() get_dated_items() get_dated_queryset() get_paginator() head() http_method_not_allowed() paginate_queryset() render_to_response() setup()

DayArchiveView

Reference Class-based generic views - flattened index Date-based views

Methods as_view() dispatch() get() get_context_data() get_date_list() get_dated_items() get_dated_queryset() get_next_day() get_next_month() get_paginator() get_previous_day() get_previous_month() head() http_method_not_allowed() paginate_queryset() render_to_response() setup()

TodayArchiveView

Reference Class-based generic views - flattened index Date-based views

Methods as_view() dispatch() get() get_context_data() get_date_list() get_dated_items() get_dated_queryset() get_next_day() get_next_month() get_paginator() get_previous_day() get_previous_month() head() http_method_not_allowed() paginate_queryset() render_to_response() setup()

ArchiveIndexView

Reference Generic date views

classArchiveIndexView[source] : A top-level index page showing the “latest” objects, by date. Objects with a date in the future are not included unless you set allow_future to True.

YearArchiveView

Reference Generic date views

classYearArchiveView[source] : A yearly archive page showing all available months in a given year. Objects with a date in the future are not displayed unless you set allow_future to True.

MonthArchiveView

Reference Generic date views

classMonthArchiveView[source] : A monthly archive page showing all objects in a given month. Objects with a date in the future are not displayed unless you set allow_future to True.

TodayArchiveView

Reference Generic date views

classTodayArchiveView[source] : A day archive page showing all objects for today. This is exactly the same as django.views.generic.dates.DayArchiveView, except today’s date is used instead of the year/month/day arguments.

DetailView

Reference Generic display views

classdjango.views.generic.detail.DetailView : While this view is executing, self.object will contain the object that the view is operating upon. classdjango.views.generic.detail.BaseDetailView : A base view for displaying a single object.

ModelFormMixin

Reference Editing mixins

classdjango.views.generic.edit.ModelFormMixin : A form mixin that provides facilities for working with a ModelForm, rather than a standalone form.

MultipleObjectMixin

Reference Multiple object mixins

`context_object_name` : Designates the name of the variable to use in the context. `get_queryset()` : Get the list of items for this view. This must be an iterable and may be a queryset (in which queryset-specific behavior will be enabled).

SingleObjectMixin

Reference Single object mixins

If [`context_object_name`](#django.views.generic.detail.SingleObjectMixin.context_object_name) is not set, the context name will be constructed from the `model_name` of the model that the queryset is composed from. For example, the model `Article` would have context object named `'article'`.

Admin actions

Reference

For example, here’s the user module from Django’s built-in django.contrib.auth app: WARNING: The “delete selected objects” action uses QuerySet.delete() for efficiency reasons, which > has an important caveat: your model’s delete() method will not be > called.

Writing action functions

Reference Admin actions Writing actions

Action functions are regular functions that take three arguments: The current ModelAdmin An HttpRequest representing the current request, A QuerySet containing the set of objects selected by the user.

Reference Admin actions Advanced action techniques

By default, after an action is performed the user is redirected back to the original change list page. However, some actions, especially more complex ones, will need to return intermediate pages.

The action decorator

Reference Admin actions

action(*,permissions=None,description=None)[source] : This decorator can be used for setting specific attributes on custom action functions that can be used with actions:

ModelAdmin options

Reference The Django admin site ModelAdmin objects

ModelAdmin.list_filter : Set list_filter to activate filters in the right sidebar of the change list page of the admin. ModelAdmin.list_max_show_all : Set list_max_show_all to control how many items can appear on a “Show all” admin change list page.