djangodocs.org

674 sections in Django 4.2 Search all versions →

YearArchiveView

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

classYearArchiveView Attributes (with optional accessor): allow_empty [get_allow_empty()] allow_future [get_allow_future()] content_type context_object_name [get_context_object_name()] date_field [get_date_field()] extra_context http_method_names make_object_list [get_make_object_list()] model ordering [get_ordering()] paginate_by [get_paginate_by()] paginate_orphans [get_paginate_orphans()] paginator_class queryset [get_queryset()] response_class [render_to_response()] template_engine template_name [get_template_names()] template_name_suffix year [get_year()] year_format [get_year_format()] Methods

MonthArchiveView

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

… Attributes (with optional accessor): allow_empty [get_allow_empty()] allow_future [get_allow_future()] content_type context_object_name [get_context_object_name()] date_field [get_date_field()] extra_context http_method_names model month [get_month()] month_format [get_month_format()] ordering [get_ordering()] paginate_by [get_paginate_by()] paginate_orphans [get_paginate_orphans()] paginator_class queryset [get_queryset()] response_class [render_to_response()] template_engine template_name [get_template_names()] template_name_suffix year [get_year()] year_format [get_year_format()] Methods

WeekArchiveView

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

… Attributes (with optional accessor): allow_empty [get_allow_empty()] allow_future [get_allow_future()] content_type context_object_name [get_context_object_name()] date_field [get_date_field()] extra_context http_method_names model ordering [get_ordering()] paginate_by [get_paginate_by()] paginate_orphans [get_paginate_orphans()] paginator_class queryset [get_queryset()] response_class [render_to_response()] template_engine template_name [get_template_names()] template_name_suffix week [get_week()] week_format [get_week_format()] year [get_year()] year_format [get_year_format()] Methods

DayArchiveView

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

… allow_empty [get_allow_empty()] allow_future [get_allow_future()] content_type context_object_name [get_context_object_name()] date_field [get_date_field()] day [get_day()] day_format [get_day_format()] extra_context http_method_names model month [get_month()] month_format [get_month_format()] ordering [get_ordering()] paginate_by [get_paginate_by()] paginate_orphans [get_paginate_orphans()] paginator_class queryset [get_queryset()] response_class [render_to_response()] template_engine template_name [get_template_names()] template_name_suffix year [get_year()] year_format [get_year_format()] Methods

TodayArchiveView

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

… allow_empty [get_allow_empty()] allow_future [get_allow_future()] content_type context_object_name [get_context_object_name()] date_field [get_date_field()] day [get_day()] day_format [get_day_format()] extra_context http_method_names model month [get_month()] month_format [get_month_format()] ordering [get_ordering()] paginate_by [get_paginate_by()] paginate_orphans [get_paginate_orphans()] paginator_class queryset [get_queryset()] response_class [render_to_response()] template_engine template_name [get_template_names()] template_name_suffix year [get_year()] year_format [get_year_format()] Methods

DateDetailView

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

… (with optional accessor): allow_future [get_allow_future()] content_type context_object_name [get_context_object_name()] date_field [get_date_field()] day [get_day()] day_format [get_day_format()] extra_context http_method_names model month [get_month()] month_format [get_month_format()] pk_url_kwarg query_pk_and_slug queryset [get_queryset()] response_class [render_to_response()] slug_field [get_slug_field()] slug_url_kwarg template_engine template_name [get_template_names()] template_name_field template_name_suffix year [get_year()] year_format [get_year_format()] Methods

WeekArchiveView

Reference Generic date views

classWeekArchiveView : A weekly archive page showing all objects in a given week. Objects with a date in the future are not displayed unless you set allow_future to True.

DayArchiveView

Reference Generic date views

classDayArchiveView : A day archive page showing all objects in a given day. Days in the future throw a 404 error, regardless of whether any objects exist for future days, unless you set allow_future to True.

BaseDateListView

Reference Date-based mixins

classBaseDateListView : A base class that provides common behavior for all date-based views. There won’t normally be a reason to instantiate BaseDateListView; instantiate one of the subclasses instead.

ModelAdmin options

Reference The Django admin site ModelAdmin objects

The ModelAdmin is very flexible. It has several options for dealing with customizing the interface. All options are defined on the ModelAdmin subclass: ModelAdmin.actions : A list of actions to make available on the change list page.

ModelAdmin options

Reference The Django admin site ModelAdmin objects

ModelAdmin.list_display_links : Use list_display_links to control if and which fields in list_display should be linked to the “change” page for an object.

ModelAdmin options

Reference The Django admin site ModelAdmin objects

ModelAdmin.autocomplete_fields : autocomplete_fields is a list of ForeignKey and/or ManyToManyField fields you would like to change to Select2 autocomplete inputs. ModelAdmin.raw_id_fields : By default, Django’s admin uses a select-box interface (<select>) for fields that are ForeignKey.

ModelAdmin methods

Reference The Django admin site ModelAdmin objects

Call super().delete_model() to delete the object using Model.delete(). ModelAdmin.delete_queryset(request,queryset) : The delete_queryset() method is given the HttpRequest and a QuerySet of objects to be deleted. Override this method to customize the deletion process for the “delete selected objects” action.

ModelAdmin methods

Reference The Django admin site ModelAdmin objects

This is how list_filter works, for example. The lookups are similar to what’s used in QuerySet.filter() (e.g. [email protected]). Since the lookups in the query string can be manipulated by the user, they must be sanitized to prevent unauthorized data exposure.

ModelAdmin methods

Reference The Django admin site ModelAdmin objects

ModelAdmin.get_queryset(request) : The get_queryset method on a ModelAdmin returns a QuerySet of all model instances that can be edited by the admin site.

ModelAdmin methods

Reference The Django admin site ModelAdmin objects

ModelAdmin.response_delete(request,obj_display,obj_id) : Determines the HttpResponse for the delete_view() stage. ModelAdmin.get_formset_kwargs(request,obj,inline,prefix) : A hook for customizing the keyword arguments passed to the constructor of a formset.

Manager methods

Reference django.contrib.auth User model

classmodels.UserManager : The User model has a custom manager that has the following helper methods (in addition to the methods provided by BaseUserManager):

Reference django.contrib.auth Authentication backends

The following backends are available in django.contrib.auth.backends: classBaseBackend : A base class that provides default implementations for all required methods. By default, it will reject any user and provide no permissions.

Distance

Reference Geographic Database Functions

… more resource-intensive). In the following example, the distance from the city of Hobart to every other PointField in the AustraliaCity queryset is calculated: NOTE: Because the distance attribute is a > Distance object, you can easily express > the value …