1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Fixed #35682 -- Updated docstrings for base view classes which require a response mixin.

This commit is contained in:
Yash 2024-09-04 20:10:27 +05:30 committed by Sarah Boyce
parent 80c3697e96
commit dc626fbe3a
4 changed files with 49 additions and 13 deletions

View File

@ -300,7 +300,11 @@ class DateMixin:
class BaseDateListView(MultipleObjectMixin, DateMixin, View): class BaseDateListView(MultipleObjectMixin, DateMixin, View):
"""Abstract base class for date-based views displaying a list of objects.""" """
Base class for date-based views displaying a list of objects.
This requires subclassing to provide a response mixin.
"""
allow_empty = False allow_empty = False
date_list_period = "year" date_list_period = "year"
@ -388,7 +392,9 @@ class BaseDateListView(MultipleObjectMixin, DateMixin, View):
class BaseArchiveIndexView(BaseDateListView): class BaseArchiveIndexView(BaseDateListView):
""" """
Base class for archives of date-based items. Requires a response mixin. Base view for archives of date-based items.
This requires subclassing to provide a response mixin.
""" """
context_object_name = "latest" context_object_name = "latest"
@ -411,7 +417,11 @@ class ArchiveIndexView(MultipleObjectTemplateResponseMixin, BaseArchiveIndexView
class BaseYearArchiveView(YearMixin, BaseDateListView): class BaseYearArchiveView(YearMixin, BaseDateListView):
"""List of objects published in a given year.""" """
Base view for a list of objects published in a given year.
This requires subclassing to provide a response mixin.
"""
date_list_period = "month" date_list_period = "month"
make_object_list = False make_object_list = False
@ -463,7 +473,11 @@ class YearArchiveView(MultipleObjectTemplateResponseMixin, BaseYearArchiveView):
class BaseMonthArchiveView(YearMixin, MonthMixin, BaseDateListView): class BaseMonthArchiveView(YearMixin, MonthMixin, BaseDateListView):
"""List of objects published in a given month.""" """
Base view for a list of objects published in a given month.
This requires subclassing to provide a response mixin.
"""
date_list_period = "day" date_list_period = "day"
@ -505,7 +519,11 @@ class MonthArchiveView(MultipleObjectTemplateResponseMixin, BaseMonthArchiveView
class BaseWeekArchiveView(YearMixin, WeekMixin, BaseDateListView): class BaseWeekArchiveView(YearMixin, WeekMixin, BaseDateListView):
"""List of objects published in a given week.""" """
Base view for a list of objects published in a given week.
This requires subclassing to provide a response mixin.
"""
def get_dated_items(self): def get_dated_items(self):
"""Return (date_list, items, extra_context) for this request.""" """Return (date_list, items, extra_context) for this request."""
@ -563,7 +581,11 @@ class WeekArchiveView(MultipleObjectTemplateResponseMixin, BaseWeekArchiveView):
class BaseDayArchiveView(YearMixin, MonthMixin, DayMixin, BaseDateListView): class BaseDayArchiveView(YearMixin, MonthMixin, DayMixin, BaseDateListView):
"""List of objects published on a given day.""" """
Base view for a list of objects published on a given day.
This requires subclassing to provide a response mixin.
"""
def get_dated_items(self): def get_dated_items(self):
"""Return (date_list, items, extra_context) for this request.""" """Return (date_list, items, extra_context) for this request."""
@ -610,7 +632,11 @@ class DayArchiveView(MultipleObjectTemplateResponseMixin, BaseDayArchiveView):
class BaseTodayArchiveView(BaseDayArchiveView): class BaseTodayArchiveView(BaseDayArchiveView):
"""List of objects published today.""" """
Base view for a list of objects published today.
This requires subclassing to provide a response mixin.
"""
def get_dated_items(self): def get_dated_items(self):
"""Return (date_list, items, extra_context) for this request.""" """Return (date_list, items, extra_context) for this request."""
@ -625,8 +651,10 @@ class TodayArchiveView(MultipleObjectTemplateResponseMixin, BaseTodayArchiveView
class BaseDateDetailView(YearMixin, MonthMixin, DayMixin, DateMixin, BaseDetailView): class BaseDateDetailView(YearMixin, MonthMixin, DayMixin, DateMixin, BaseDetailView):
""" """
Detail view of a single object on a single date; this differs from the Base detail view for a single object on a single date; this differs from the
standard DetailView by accepting a year/month/day in the URL. standard DetailView by accepting a year/month/day in the URL.
This requires subclassing to provide a response mixin.
""" """
def get_object(self, queryset=None): def get_object(self, queryset=None):

View File

@ -102,7 +102,11 @@ class SingleObjectMixin(ContextMixin):
class BaseDetailView(SingleObjectMixin, View): class BaseDetailView(SingleObjectMixin, View):
"""A base view for displaying a single object.""" """
Base view for displaying a single object.
This requires subclassing to provide a response mixin.
"""
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
self.object = self.get_object() self.object = self.get_object()

View File

@ -170,7 +170,7 @@ class BaseCreateView(ModelFormMixin, ProcessFormView):
""" """
Base view for creating a new object instance. Base view for creating a new object instance.
Using this base class requires subclassing to provide a response mixin. This requires subclassing to provide a response mixin.
""" """
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
@ -194,7 +194,7 @@ class BaseUpdateView(ModelFormMixin, ProcessFormView):
""" """
Base view for updating an existing object. Base view for updating an existing object.
Using this base class requires subclassing to provide a response mixin. This requires subclassing to provide a response mixin.
""" """
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
@ -242,7 +242,7 @@ class BaseDeleteView(DeletionMixin, FormMixin, BaseDetailView):
""" """
Base view for deleting an object. Base view for deleting an object.
Using this base class requires subclassing to provide a response mixin. This requires subclassing to provide a response mixin.
""" """
form_class = Form form_class = Form

View File

@ -148,7 +148,11 @@ class MultipleObjectMixin(ContextMixin):
class BaseListView(MultipleObjectMixin, View): class BaseListView(MultipleObjectMixin, View):
"""A base view for displaying a list of objects.""" """
Base view for displaying a list of objects.
This requires subclassing to provide a response mixin.
"""
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
self.object_list = self.get_queryset() self.object_list = self.get_queryset()