diff --git a/django/views/generic/base.py b/django/views/generic/base.py
index 5e69a8d..7f60ff0 100644
a
|
b
|
from django.utils.decorators import classonlymethod
|
8 | 8 | |
9 | 9 | logger = getLogger('django.request') |
10 | 10 | |
| 11 | |
11 | 12 | class View(object): |
12 | 13 | """ |
13 | 14 | Intentionally simple parent class for all views. Only implements |
diff --git a/django/views/generic/dates.py b/django/views/generic/dates.py
index c9e486b..2dd8883 100644
a
|
b
|
class BaseDateListView(MultipleObjectMixin, DateMixin, View):
|
212 | 212 | |
213 | 213 | return date_list |
214 | 214 | |
215 | | |
216 | | |
217 | 215 | def get_context_data(self, **kwargs): |
218 | 216 | """ |
219 | 217 | Get the context. Must return a Context (or subclass) instance. |
… |
… |
class BaseArchiveIndexView(BaseDateListView):
|
240 | 238 | date_list = self.get_date_list(qs, 'year') |
241 | 239 | |
242 | 240 | if date_list: |
243 | | object_list = qs.order_by('-'+self.get_date_field()) |
| 241 | object_list = qs.order_by('-' + self.get_date_field()) |
244 | 242 | else: |
245 | 243 | object_list = qs.none() |
246 | 244 | |
… |
… |
class BaseMonthArchiveView(YearMixin, MonthMixin, BaseDateListView):
|
327 | 325 | }) |
328 | 326 | |
329 | 327 | |
330 | | |
331 | 328 | class MonthArchiveView(MultipleObjectTemplateResponseMixin, BaseMonthArchiveView): |
332 | 329 | """ |
333 | 330 | List of objects published in a given year. |
… |
… |
class BaseDayArchiveView(YearMixin, MonthMixin, DayMixin, BaseDateListView):
|
416 | 413 | }) |
417 | 414 | |
418 | 415 | |
419 | | |
420 | 416 | class DayArchiveView(MultipleObjectTemplateResponseMixin, BaseDayArchiveView): |
421 | 417 | """ |
422 | 418 | List of objects published on a given day. |
… |
… |
class BaseDateDetailView(YearMixin, MonthMixin, DayMixin, DateMixin, BaseDetailV
|
477 | 473 | return super(BaseDetailView, self).get_object(queryset=qs) |
478 | 474 | |
479 | 475 | |
480 | | |
481 | 476 | class DateDetailView(SingleObjectTemplateResponseMixin, BaseDateDetailView): |
482 | 477 | """ |
483 | 478 | Detail view of a single object on a single date; this differs from the |
… |
… |
def _date_from_string(year, year_format, month, month_format, day='', day_format
|
498 | 493 | except ValueError: |
499 | 494 | raise Http404(u"Invalid date string '%s' given format '%s'" % (datestr, format)) |
500 | 495 | |
| 496 | |
501 | 497 | def _month_bounds(date): |
502 | 498 | """ |
503 | 499 | Helper: return the first and last days of the month for the given date. |
… |
… |
def _month_bounds(date):
|
510 | 506 | |
511 | 507 | return first_day, last_day |
512 | 508 | |
| 509 | |
513 | 510 | def _get_next_prev_month(generic_view, naive_result, is_previous, use_first_day): |
514 | 511 | """ |
515 | 512 | Helper: Get the next or the previous valid date. The idea is to allow |
… |
… |
def _get_next_prev_month(generic_view, naive_result, is_previous, use_first_day)
|
582 | 579 | else: |
583 | 580 | return None |
584 | 581 | |
| 582 | |
585 | 583 | def _date_lookup_for_field(field, date): |
586 | 584 | """ |
587 | 585 | Get the lookup kwargs for looking up a date against a given Field. If the |
… |
… |
def _date_lookup_for_field(field, date):
|
597 | 595 | return {'%s__range' % field.name: date_range} |
598 | 596 | else: |
599 | 597 | return {field.name: date} |
600 | | |
diff --git a/django/views/generic/edit.py b/django/views/generic/edit.py
index 931a2d3..33a3127 100644
a
|
b
|
class ModelFormMixin(FormMixin, SingleObjectMixin):
|
102 | 102 | self.object = form.save() |
103 | 103 | return super(ModelFormMixin, self).form_valid(form) |
104 | 104 | |
105 | | def form_invalid(self, form): |
106 | | return self.render_to_response(self.get_context_data(form=form)) |
107 | | |
108 | 105 | def get_context_data(self, **kwargs): |
109 | 106 | context = kwargs |
110 | 107 | if self.object: |
… |
… |
class BaseCreateView(ModelFormMixin, ProcessFormView):
|
169 | 166 | def put(self, *args, **kwargs): |
170 | 167 | return self.post(*args, **kwargs) |
171 | 168 | |
| 169 | |
172 | 170 | class CreateView(SingleObjectTemplateResponseMixin, BaseCreateView): |
173 | 171 | """ |
174 | 172 | View for creating an new object instance, |
… |
… |
class DeletionMixin(object):
|
227 | 225 | raise ImproperlyConfigured( |
228 | 226 | "No URL to redirect to. Provide a success_url.") |
229 | 227 | |
| 228 | |
230 | 229 | class BaseDeleteView(DeletionMixin, BaseDetailView): |
231 | 230 | """ |
232 | 231 | Base view for deleting an object. |
… |
… |
class BaseDeleteView(DeletionMixin, BaseDetailView):
|
234 | 233 | Using this base class requires subclassing to provide a response mixin. |
235 | 234 | """ |
236 | 235 | |
| 236 | |
237 | 237 | class DeleteView(SingleObjectTemplateResponseMixin, BaseDeleteView): |
238 | 238 | """ |
239 | 239 | View for deleting an object retrieved with `self.get_object()`, |
diff --git a/django/views/generic/list.py b/django/views/generic/list.py
index 7b817a5..9f1c8aa 100644
a
|
b
|
class BaseListView(MultipleObjectMixin, View):
|
119 | 119 | context = self.get_context_data(object_list=self.object_list) |
120 | 120 | return self.render_to_response(context) |
121 | 121 | |
| 122 | |
122 | 123 | class MultipleObjectTemplateResponseMixin(TemplateResponseMixin): |
123 | 124 | template_name_suffix = '_list' |
124 | 125 | |
… |
… |
class MultipleObjectTemplateResponseMixin(TemplateResponseMixin):
|
139 | 140 | |
140 | 141 | return names |
141 | 142 | |
| 143 | |
142 | 144 | class ListView(MultipleObjectTemplateResponseMixin, BaseListView): |
143 | 145 | """ |
144 | 146 | Render some list of objects, set by `self.model` or `self.queryset`. |