Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
@freakboy3742 freakboy3742 authored
View
1  django/views/generic/base.py
@@ -8,6 +8,7 @@
logger = getLogger('django.request')
+
class View(object):
"""
Intentionally simple parent class for all views. Only implements
View
11 django/views/generic/dates.py
@@ -212,8 +212,6 @@ def get_date_list(self, queryset, date_type):
return date_list
-
-
def get_context_data(self, **kwargs):
"""
Get the context. Must return a Context (or subclass) instance.
@@ -240,7 +238,7 @@ def get_dated_items(self):
date_list = self.get_date_list(qs, 'year')
if date_list:
- object_list = qs.order_by('-'+self.get_date_field())
+ object_list = qs.order_by('-' + self.get_date_field())
else:
object_list = qs.none()
@@ -327,7 +325,6 @@ def get_dated_items(self):
})
-
class MonthArchiveView(MultipleObjectTemplateResponseMixin, BaseMonthArchiveView):
"""
List of objects published in a given year.
@@ -416,7 +413,6 @@ def _get_dated_items(self, date):
})
-
class DayArchiveView(MultipleObjectTemplateResponseMixin, BaseDayArchiveView):
"""
List of objects published on a given day.
@@ -477,7 +473,6 @@ def get_object(self, queryset=None):
return super(BaseDetailView, self).get_object(queryset=qs)
-
class DateDetailView(SingleObjectTemplateResponseMixin, BaseDateDetailView):
"""
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
except ValueError:
raise Http404(u"Invalid date string '%s' given format '%s'" % (datestr, format))
+
def _month_bounds(date):
"""
Helper: return the first and last days of the month for the given date.
@@ -510,6 +506,7 @@ def _month_bounds(date):
return first_day, last_day
+
def _get_next_prev_month(generic_view, naive_result, is_previous, use_first_day):
"""
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)
else:
return None
+
def _date_lookup_for_field(field, date):
"""
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):
return {'%s__range' % field.name: date_range}
else:
return {field.name: date}
-
View
6 django/views/generic/edit.py
@@ -102,9 +102,6 @@ def form_valid(self, form):
self.object = form.save()
return super(ModelFormMixin, self).form_valid(form)
- def form_invalid(self, form):
- return self.render_to_response(self.get_context_data(form=form))
-
def get_context_data(self, **kwargs):
context = kwargs
if self.object:
@@ -169,6 +166,7 @@ def post(self, request, *args, **kwargs):
def put(self, *args, **kwargs):
return self.post(*args, **kwargs)
+
class CreateView(SingleObjectTemplateResponseMixin, BaseCreateView):
"""
View for creating an new object instance,
@@ -227,6 +225,7 @@ def get_success_url(self):
raise ImproperlyConfigured(
"No URL to redirect to. Provide a success_url.")
+
class BaseDeleteView(DeletionMixin, BaseDetailView):
"""
Base view for deleting an object.
@@ -234,6 +233,7 @@ class BaseDeleteView(DeletionMixin, BaseDetailView):
Using this base class requires subclassing to provide a response mixin.
"""
+
class DeleteView(SingleObjectTemplateResponseMixin, BaseDeleteView):
"""
View for deleting an object retrieved with `self.get_object()`,
View
2  django/views/generic/list.py
@@ -119,6 +119,7 @@ def get(self, request, *args, **kwargs):
context = self.get_context_data(object_list=self.object_list)
return self.render_to_response(context)
+
class MultipleObjectTemplateResponseMixin(TemplateResponseMixin):
template_name_suffix = '_list'
@@ -139,6 +140,7 @@ def get_template_names(self):
return names
+
class ListView(MultipleObjectTemplateResponseMixin, BaseListView):
"""
Render some list of objects, set by `self.model` or `self.queryset`.
Please sign in to comment.
Something went wrong with that request. Please try again.