class MonthMixin
from django.views.generic.dates import MonthMixin
Mixin for views manipulating month-based data.
Attributes
| Defined in | |
|---|---|
                                    
                                        month = None
                                    
                                 | 
                                MonthMixin | 
                                    
                                        month_format = '%b'
                                    
                                 | 
                                MonthMixin | 
Methods
                            
                                
                                    def
                                    _get_current_month(self, date):
                                
                                
                                    MonthMixin
                                
                                ¶
                            
                        
                        
                                    def
                                    _get_current_month(self, date):
                                
                                
                                    MonthMixin
                                
                                ¶
                            Return the start date of the previous interval.
136 137 138 139 140  | def _get_current_month(self, date): """ Return the start date of the previous interval. """ return date.replace(day=1)  | 
                            
                                
                                    def
                                    _get_next_month(self, date):
                                
                                
                                    MonthMixin
                                
                                ¶
                            
                        
                        
                                    def
                                    _get_next_month(self, date):
                                
                                
                                    MonthMixin
                                
                                ¶
                            Return the start date of the next interval. The interval is defined by start date <= item date < next start date.
122 123 124 125 126 127 128 129 130 131 132 133  | def _get_next_month(self, date): """ Return the start date of the next interval. The interval is defined by start date <= item date < next start date. """ if date.month == 12: try: return date.replace(year=date.year + 1, month=1, day=1) except ValueError: raise Http404(_("Date out of range")) else: return date.replace(month=date.month + 1, day=1)  | 
                            
                                
                                    def
                                    get_month(self):
                                
                                
                                    MonthMixin
                                
                                ¶
                            
                        
                        
                                    def
                                    get_month(self):
                                
                                
                                    MonthMixin
                                
                                ¶
                            Return the month for which this view should display data.
95 96 97 98 99 100 101 102 103 104 105 106 107 108  | 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(_("No month specified")) return month  | 
                            
                                
                                    def
                                    get_month_format(self):
                                
                                
                                    MonthMixin
                                
                                ¶
                            
                        
                        
                                    def
                                    get_month_format(self):
                                
                                
                                    MonthMixin
                                
                                ¶
                            Get a month format string in strptime syntax to be used to parse the month from url variables.
88 89 90 91 92 93  | 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
                                
                                ¶
                            
                        
                        
                                    def
                                    get_next_month(self, date):
                                
                                
                                    MonthMixin
                                
                                ¶
                            Get the next valid month.
110 111 112 113 114  | def get_next_month(self, date): """ Get the next valid month. """ return _get_next_prev(self, date, is_previous=False, period='month')  | 
                            
                                
                                    def
                                    get_previous_month(self, date):
                                
                                
                                    MonthMixin
                                
                                ¶
                            
                        
                        
                                    def
                                    get_previous_month(self, date):
                                
                                
                                    MonthMixin
                                
                                ¶
                            Get the previous valid month.
116 117 118 119 120  | def get_previous_month(self, date): """ Get the previous valid month. """ return _get_next_prev(self, date, is_previous=True, period='month')  |