barseghyanartur / django-fobi

Form generator/builder application for Django done right: customisable, modular, user- and developer- friendly.
https://pypi.python.org/pypi/django-fobi
484 stars 112 forks source link

Form Export fails / simplejson #242

Closed nerrixde closed 3 years ago

nerrixde commented 4 years ago

When I export a form to json I get this traceback:

ERROR 2020-06-20 14:44:37,258 [/var/www/pyform/fobi/lib/python3.6/site-packages/django/core/handlers/exception.py:135] Internal Server Error: /en/fobi/forms/export/5/
Traceback (most recent call last):
  File "/var/www/pyform/fobi/lib/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/var/www/pyform/fobi/lib/python3.6/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
    response = self._get_response(request)
  File "/var/www/pyform/fobi/lib/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/var/www/pyform/fobi/lib/python3.6/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/var/www/pyform/fobi/lib/python3.6/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/var/www/pyform/fobi/lib/python3.6/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/var/www/pyform/fobi/lib/python3.6/site-packages/fobi/views/function_based.py", line 2357, in export_form_entry
    json.dumps(data, cls=DjangoJSONEncoder),
  File "/var/www/pyform/fobi/lib/python3.6/site-packages/simplejson/__init__.py", line 397, in dumps
    **kw).encode(obj)
TypeError: __init__() got an unexpected keyword argument 'encoding'

I read #217 but despite downgrading to simplejson=3.8.0 the error stays the above. I verified I'm actually using simplejson=3.8.0 by doing __version__. Fobi runs with the latest master-branch-code.

practiceryan commented 3 years ago

I'm still having the original Form Export failure issue.

Hopefully to keep things simple, the Fobi related error lines: /usr/local/lib/python3.9/site-packages/fobi/views.py, line 2355, in export_form_entry json.dumps(data, cls=DjangoJSONEncoder),

I have a custom form handler, however, as in the db_store handler the saved_data is as below: saved_data=json.dumps(cleaned_data, cls=DjangoJSONEncoder)

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.9/site-packages/django/core/handlers/base.py", line 179, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.9/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/fobi/views.py", line 2355, in export_form_entry
    json.dumps(data, cls=DjangoJSONEncoder),
  File "/usr/local/lib/python3.9/site-packages/simplejson/__init__.py", line 398, in dumps
    return cls(

Exception Type: TypeError at /api/fobi/forms/export/2/
Exception Value: __init__() got an unexpected keyword argument 'encoding'

I'm using the most recent version of Fobi, what am I missing?

barseghyanartur commented 3 years ago

@practiceryan:

Strange. I'll check/fix it asap. Thanks for reporting.

barseghyanartur commented 3 years ago

@practiceryan:

Fixed in a branch 242-Form-Export-fails-simplejson. Could you extensively test it and see if it works well for you?

practiceryan commented 3 years ago

That's perfect, works perfectly and is correctly imported

barseghyanartur commented 3 years ago

@practiceryan:

Released in 0.17.1.