Skip to content

Commit

Permalink
fix bug in formsets
Browse files Browse the repository at this point in the history
  • Loading branch information
francesco-filicetti committed Apr 17, 2020
1 parent 8b55928 commit 61e6765
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions django_form_builder/formsets.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import ast
import re
import sys
from django import forms

from django.conf import settings

def get_empty_form(form_class=forms.Form):
class Dynamic(form_class):
Expand All @@ -26,8 +28,9 @@ def build_formset(choices, extra=0, required=False, prefix='form', data=None):
field_dict = ast.literal_eval(coldict)
field_type_name = field_dict['type']
del field_dict['type']
custom_field = getattr(sys.modules[__name__], field_type_name)(**field_dict) \
if hasattr(sys.modules[__name__], field_type_name) else CustomCharField()
custom_field = getattr(sys.modules[__package__ + '.dynamic_fields'], field_type_name)(**field_dict) \
if hasattr(sys.modules[__package__ + '.dynamic_fields'], field_type_name) \
else getattr(sys.modules[__package__ + '.dynamic_fields'], 'CustomCharField')
custom_widget = getattr(settings, 'CUSTOM_WIDGETS').get(field_type_name) \
if hasattr(settings, 'CUSTOM_WIDGETS') else None
if custom_widget:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

setup(
name='django-form-builder',
version='0.9.4',
version='0.9.5',
packages=find_packages(),
include_package_data=True,
license='BSD License',
Expand Down

0 comments on commit 61e6765

Please sign in to comment.