class YearMixin

from django.views.generic.dates import YearMixin
Hierarchy diagram Documentation Source code
Mixin for views manipulating year-based data.

Attributes

  Defined in
year = None YearMixin
year_format = '%Y' YearMixin
Expand Collapse

Methods

def _get_current_year(self, date): YearMixin

Return the start date of the current interval.
65
66
67
68
69
def _get_current_year(self, date):
    """
    Return the start date of the current interval.
    """
    return date.replace(month=1, day=1)

def _get_next_year(self, date): YearMixin

Return the start date of the next interval.

The interval is defined by start date <= item date < next start date.
57
58
59
60
61
62
def _get_next_year(self, date):
    """
    Return the start date of the next interval.
    The interval is defined by start date <= item date < next start date.
    """
    return date.replace(year=date.year + 1, month=1, day=1)

def get_next_year(self, date): YearMixin

Get the next valid year.
45
46
47
48
49
def get_next_year(self, date):
    """
    Get the next valid year.
    """
    return _get_next_prev(self, date, is_previous=False, period='year')

def get_previous_year(self, date): YearMixin

Get the previous valid year.
51
52
53
54
55
def get_previous_year(self, date):
    """
    Get the previous valid year.
    """
    return _get_next_prev(self, date, is_previous=True, period='year')

def get_year(self): YearMixin

Return the year for which this view should display data.
30
31
32
33
34
35
36
37
38
39
40
41
42
43
def get_year(self):
    """
    Return the year for which this view should display data.
    """
    year = self.year
    if year is None:
        try:
            year = self.kwargs['year']
        except KeyError:
            try:
                year = self.request.GET['year']
            except KeyError:
                raise Http404(_("No year specified"))
    return year

def get_year_format(self): YearMixin

Get a year format string in strptime syntax to be used to parse the
year from url variables.
23
24
25
26
27
28
def get_year_format(self):
    """
    Get a year format string in strptime syntax to be used to parse the
    year from url variables.
    """
    return self.year_format