Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #15061 -- Removed a redundant method implementation in the clas…

…s-based ModelFormMixin, and did some PEP8 cleanup. Thanks to rasca for the report and patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15341 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 461f01b7a66a1d12cebf786892baccb6cee2e6c1 1 parent 1f5309a
Russell Keith-Magee authored January 27, 2011
1  django/views/generic/base.py
@@ -8,6 +8,7 @@
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
11  django/views/generic/dates.py
@@ -212,8 +212,6 @@ def get_date_list(self, queryset, date_type):
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.
@@ -240,7 +238,7 @@ def get_dated_items(self):
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
 
@@ -327,7 +325,6 @@ def get_dated_items(self):
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.
@@ -416,7 +413,6 @@ def _get_dated_items(self, date):
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.
@@ -477,7 +473,6 @@ def get_object(self, queryset=None):
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
@@ -498,6 +493,7 @@ 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.
@@ -510,6 +506,7 @@ 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
@@ -582,6 +579,7 @@ 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
@@ -597,4 +595,3 @@ 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  
-
6  django/views/generic/edit.py
@@ -102,9 +102,6 @@ def form_valid(self, form):
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:
@@ -169,6 +166,7 @@ def post(self, request, *args, **kwargs):
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,
@@ -227,6 +225,7 @@ def get_success_url(self):
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.
@@ -234,6 +233,7 @@ 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()`,
2  django/views/generic/list.py
@@ -119,6 +119,7 @@ def get(self, request, *args, **kwargs):
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
 
@@ -139,6 +140,7 @@ def get_template_names(self):
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`.

0 notes on commit 461f01b

Please sign in to comment.
Something went wrong with that request. Please try again.