Класс DayMixin (Django 2.1)

from django.views.generic.dates import DayMixin

Mixin for views manipulating day-based data.

Атрибуты

  Определено в
day = None DayMixin
day_format = '%d' DayMixin

Методы

Возвращает дату начала текущего интервала.

def _get_current_day(self, date):
    """Return the start date of the current interval."""
    return date

Return the day for which this view should display data.

def get_day(self):
    """Return the day for which this view should display data."""
    day = self.day
    if day is None:
        try:
            day = self.kwargs['day']
        except KeyError:
            try:
                day = self.request.GET['day']
            except KeyError:
                raise Http404(_("No day specified"))
    return day

Get a day format string in strptime syntax to be used to parse the day from url variables.

def get_day_format(self):
    """
    Get a day format string in strptime syntax to be used to parse the day
    from url variables.
    """
    return self.day_format

Возвращает дату начала следующего интервала. Интервал определяется датой начала <= дата элемента < следующая дата начала.

def _get_next_day(self, date):
    """
    Return the start date of the next interval.
    The interval is defined by start date <= item date < next start date.
    """
    return date + datetime.timedelta(days=1)

Get the next valid day.

def get_next_day(self, date):
    """Get the next valid day."""
    return _get_next_prev(self, date, is_previous=False, period='day')

Get the previous valid day.

def get_previous_day(self, date):
    """Get the previous valid day."""
    return _get_next_prev(self, date, is_previous=True, period='day')