diff --git a/django_form_builder/formsets.py b/django_form_builder/formsets.py index 83407f2..b7ee830 100644 --- a/django_form_builder/formsets.py +++ b/django_form_builder/formsets.py @@ -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): @@ -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: diff --git a/setup.py b/setup.py index 5e95f47..3c40e0d 100644 --- a/setup.py +++ b/setup.py @@ -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',