Skip to content

Commit

Permalink
Fix issue with get_form_class method
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Vetter committed Oct 23, 2013
1 parent bea43ab commit 9a92bee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion fancypages/api/serialisers.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def restore_object(self, attrs, instance=None):
def get_form_class(self, obj):
model = self.object.__class__
get_form_class = getattr(model, 'get_form_class')
if get_form_class:
if get_form_class and get_form_class():
return modelform_factory(model, form=get_form_class())

form_class = getattr(
Expand Down
16 changes: 9 additions & 7 deletions fancypages/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,15 @@ def get_form_kwargs(self):

def get_form_class(self):
model = self.object.__class__
form_class = getattr(model, 'form_class')
if not form_class:
form_class = getattr(
forms,
"%sForm" % model.__name__,
forms.BlockForm
)
get_form_class = getattr(model, 'get_form_class')
if get_form_class and get_form_class():
return modelform_factory(model, form=get_form_class())

form_class = getattr(
forms,
"%sForm" % model.__name__,
forms.BlockForm
)
return modelform_factory(model, form=form_class)

def form_invalid(self, form):
Expand Down

0 comments on commit 9a92bee

Please sign in to comment.