Skip to content

Commit

Permalink
Moved calling instantiate_enhanced_formsets to Process views and not
Browse files Browse the repository at this point in the history
Mixins
  • Loading branch information
rasca committed Jun 1, 2015
1 parent c9f4338 commit e38ec2a
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions enhanced_cbv/views/edit.py
Expand Up @@ -127,10 +127,6 @@ class FormSetsMixin(object):
formsets = [] # must be a list of BaseGenericFormSet
success_url = None

def dispatch(self, request, *args, **kwargs):
self.instantiate_enhanced_formsets()
return super(FormSetsMixin, self).dispatch(request, *args, **kwargs)

def get_formsets(self):
return self.formsets

Expand Down Expand Up @@ -280,6 +276,11 @@ class ProcessFormSetsView(View):
"""
A mixin that processes formsets on POST
"""

def dispatch(self, request, *args, **kwargs):
self.instantiate_enhanced_formsets()
return super(ProcessFormSetsView, self).dispatch(request, *args, **kwargs)

def get(self, request, *args, **kwargs):
self.construct_formsets()
return self.render_to_response(self.get_context_data())
Expand All @@ -295,7 +296,7 @@ def put(self, request, *args, **kwargs):
return self.post(*args, **kwargs)


class ProcessInlineFormSetsView(View):
class ProcessInlineFormSetsView(ProcessFormSetsView):
"""
A mixin that processes a model instance and it's inline formsets on POST
Expand Down Expand Up @@ -347,9 +348,6 @@ def post(self, request, *args, **kwargs):
self.construct_formsets()
return self.form_invalid(form)

def put(self, request, *args, **kwargs):
return self.post(*args, **kwargs)


class BaseFormSetsView(FormSetsMixin, ProcessFormSetsView):
"""
Expand Down

0 comments on commit e38ec2a

Please sign in to comment.