class MonthMixin

from django.views.generic.dates import MonthMixin
Hierarchy diagram Documentation Source code

Attributes

  Defined in
month = None MonthMixin
month_format = '%b' MonthMixin
Expand Collapse

Methods

def get_month(self): MonthMixin

Return the month for which this view should display data
48
49
50
51
52
53
54
55
56
57
58
59
def get_month(self):
    "Return the month for which this view should display data"
    month = self.month
    if month is None:
        try:
            month = self.kwargs['month']
        except KeyError:
            try:
                month = self.request.GET['month']
            except KeyError:
                raise Http404(_(u"No month specified"))
    return month

def get_month_format(self): MonthMixin

Get a month format string in strptime syntax to be used to parse the
month from url variables.
41
42
43
44
45
46
def get_month_format(self):
    """
    Get a month format string in strptime syntax to be used to parse the
    month from url variables.
    """
    return self.month_format

def get_next_month(self, date): MonthMixin

Get the next valid month.
61
62
63
64
65
66
67
def get_next_month(self, date):
    """
    Get the next valid month.
    """
    first_day, last_day = _month_bounds(date)
    next = (last_day + datetime.timedelta(days=1)).replace(day=1)
    return _get_next_prev_month(self, next, is_previous=False, use_first_day=True)

def get_previous_month(self, date): MonthMixin

Get the previous valid month.
69
70
71
72
73
74
75
def get_previous_month(self, date):
    """
    Get the previous valid month.
    """
    first_day, last_day = _month_bounds(date)
    prev = (first_day - datetime.timedelta(days=1))
    return _get_next_prev_month(self, prev, is_previous=True, use_first_day=True)