Skip to content

Commit

Permalink
Fixed #35682 -- Updated docstrings for base view classes which requir…
Browse files Browse the repository at this point in the history
…e a response mixin.
  • Loading branch information
YashRaj1506 authored and sarahboyce committed Oct 15, 2024
1 parent 80c3697 commit dc626fb
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 13 deletions.
44 changes: 36 additions & 8 deletions django/views/generic/dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,11 @@ def _make_single_date_lookup(self, date):


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
date_list_period = "year"
Expand Down Expand Up @@ -388,7 +392,9 @@ def get_date_list(self, queryset, date_type=None, ordering="ASC"):

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"
Expand All @@ -411,7 +417,11 @@ class ArchiveIndexView(MultipleObjectTemplateResponseMixin, BaseArchiveIndexView


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"
make_object_list = False
Expand Down Expand Up @@ -463,7 +473,11 @@ class YearArchiveView(MultipleObjectTemplateResponseMixin, BaseYearArchiveView):


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"

Expand Down Expand Up @@ -505,7 +519,11 @@ class MonthArchiveView(MultipleObjectTemplateResponseMixin, BaseMonthArchiveView


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):
"""Return (date_list, items, extra_context) for this request."""
Expand Down Expand Up @@ -563,7 +581,11 @@ class WeekArchiveView(MultipleObjectTemplateResponseMixin, BaseWeekArchiveView):


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):
"""Return (date_list, items, extra_context) for this request."""
Expand Down Expand Up @@ -610,7 +632,11 @@ class DayArchiveView(MultipleObjectTemplateResponseMixin, 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):
"""Return (date_list, items, extra_context) for this request."""
Expand All @@ -625,8 +651,10 @@ class TodayArchiveView(MultipleObjectTemplateResponseMixin, BaseTodayArchiveView

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.
This requires subclassing to provide a response mixin.
"""

def get_object(self, queryset=None):
Expand Down
6 changes: 5 additions & 1 deletion django/views/generic/detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ def get_context_data(self, **kwargs):


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):
self.object = self.get_object()
Expand Down
6 changes: 3 additions & 3 deletions django/views/generic/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class BaseCreateView(ModelFormMixin, ProcessFormView):
"""
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):
Expand All @@ -194,7 +194,7 @@ class BaseUpdateView(ModelFormMixin, ProcessFormView):
"""
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):
Expand Down Expand Up @@ -242,7 +242,7 @@ class BaseDeleteView(DeletionMixin, FormMixin, BaseDetailView):
"""
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
Expand Down
6 changes: 5 additions & 1 deletion django/views/generic/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,11 @@ def get_context_data(self, *, object_list=None, **kwargs):


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):
self.object_list = self.get_queryset()
Expand Down

0 comments on commit dc626fb

Please sign in to comment.