derek-schaefer / django-json-field

Generic JSON model and form fields.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Django 1.7 compatibility

ClaudiuLSH opened this issue · comments

Not present in: commit 462edd22e5577ff9ee6477f7572b571700d1a2aa

I noticed this issue starting with: commit b787ef2dbff957c5b5a64be13f01f985d17ff05b
It might of been introduced in between those 2 commits. Please note that this 2 commits are for Django and not django-json-field.

Error bellow:

Internal Server Error: /phpanel/library/47/
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/Django-1.7a2-py2.7.egg/django/core/handlers/base.py", line 113, in get_response
response = wrapped_callback(request, _callback_args, *_callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7a2-py2.7.egg/django/contrib/admin/options.py", line 550, in wrapper
return self.admin_site.admin_view(view)(_args, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7a2-py2.7.egg/django/utils/decorators.py", line 105, in _wrapped_view
response = view_func(request, _args, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7a2-py2.7.egg/django/views/decorators/cache.py", line 52, in _wrapped_view_func
response = view_func(request, _args, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7a2-py2.7.egg/django/contrib/admin/sites.py", line 202, in inner
return view(request, _args, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7a2-py2.7.egg/django/contrib/admin/options.py", line 1420, in change_view
return self.changeform_view(request, object_id, form_url, extra_context)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7a2-py2.7.egg/django/utils/decorators.py", line 29, in _wrapper
return bound_func(_args, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7a2-py2.7.egg/django/utils/decorators.py", line 105, in _wrapped_view
response = view_func(request, _args, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7a2-py2.7.egg/django/utils/decorators.py", line 25, in bound_func
return func.get(self, type(self))(_args2, *_kwargs2)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7a2-py2.7.egg/django/db/transaction.py", line 362, in inner
return func(_args, _kwargs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7a2-py2.7.egg/django/contrib/admin/options.py", line 1356, in changeform_view
ModelForm = self.get_form(request, obj)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7a2-py2.7.egg/django/contrib/admin/options.py", line 609, in get_form
fields = flatten_fieldsets(self.get_fieldsets(request, obj))
File "/usr/local/lib/python2.7/dist-packages/Django-1.7a2-py2.7.egg/django/contrib/admin/options.py", line 347, in get_fieldsets
return [(None, {'fields': self.get_fields(request, obj)})]
File "/usr/local/lib/python2.7/dist-packages/Django-1.7a2-py2.7.egg/django/contrib/admin/options.py", line 598, in get_fields
form = self.get_form(request, obj, fields=None)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7a2-py2.7.egg/django/contrib/admin/options.py", line 634, in get_form
return modelform_factory(self.model, **defaults)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7a2-py2.7.egg/django/forms/models.py", line 541, in modelform_factory
return type(form)(class_name, (form,), form_class_attrs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7a2-py2.7.egg/django/forms/models.py", line 284, in new
opts.help_texts, opts.error_messages)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7a2-py2.7.egg/django/forms/models.py", line 214, in fields_for_model
formfield = formfield_callback(f, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7a2-py2.7.egg/django/contrib/admin/options.py", line 211, in formfield_for_dbfield
return db_field.formfield(**kwargs)
File "/usr/local/lib/python2.7/dist-packages/json_field/fields.py", line 197, in formfield
return super(JSONField, self).formfield(**defaults)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7a2-py2.7.egg/django/db/models/fields/init.py", line 1859, in formfield
return super(TextField, self).formfield(**defaults)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7a2-py2.7.egg/django/db/models/fields/init.py", line 836, in formfield
return form_class(
_defaults)
File "/usr/local/lib/python2.7/dist-packages/json_field/forms.py", line 17, in init
super(JSONFormField, self).init(_args, **kwargs)
TypeError: init() got an unexpected keyword argument 'max_length'

I've got same issue testing Django 1.7 compatibility, are you planning to fix this any time soon?

Yes, now that Django 1.7 is due to be released soon. I haven't had as much cause to use Django lately so development has fallen behind a bit.

I'd love an updated version, because the other jsonfield package also is incompatible with 1.7.

Do we have a handle on the issues that need to be addressed?

Regrettably, not yet. A pull request would be great. Otherwise, I'll try to find a fix for this (and hopefully other standing issues) before the release of 1.7.

commented

This happens as part of this change in 1.7

The <textarea> tags rendered by Textarea now include a maxlength attribute if the TextField model field has a max_length.

It looks like we may want JSONFormField to inherit from django.forms.fields.CharField instead of fields.Field

What do others think?

I've pushed a simple fix for this issue. If anyone has ideas for a more fundamental improvement here please let me know. I'll keep this issue open for a while longer.

commented

thanks @derek-schaefer.
For my own understanding, is it inappropriate for JSONFormField to inherit from django.forms.fields.CharField instead of fields.Field?

That might work. I'll need to read the source for that class to be sure.