-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to edit my Field in Admin with django-leaflet #61
Comments
@batisteo I received the same error due to having the wrong dependency installed. You want the package "jsonfield" and my guess is you currently have "django-jsonfield". It's confusing since PyPi has both of them named django-jsonfield, but |
I also released django-geojson 1.8.1 with @kevcooper fix about GEOS detection. Let us know :) |
Hi, I actually got the same error. apps : Django 1.9.7 models.py : class lieu(models.Model):
nom = models.CharField(max_length = 100)
geom = GeometryField() admin.py : from plan.models import lieu
admin.site.register(lieu, LeafletGeoAdmin) traceback : Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/fr/admin/plan/lieu/add/
Django Version: 1.9.7
Python Version: 3.4.2
Installed Applications:
['djangocms_admin_style',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'django.contrib.sites',
'django.contrib.sitemaps',
'django.contrib.staticfiles',
'django.contrib.messages',
'cms',
'menus',
'sekizai',
'treebeard',
'djangocms_text_ckeditor',
'djangocms_style',
'djangocms_column',
'filer',
'easy_thumbnails',
'cmsplugin_filer_image',
'cmsplugin_filer_file',
'cmsplugin_filer_folder',
'cmsplugin_filer_teaser',
'cmsplugin_filer_utils',
'cmsplugin_filer_video',
'djangocms_googlemap',
'djangocms_inherit',
'djangocms_link',
'reversion',
'bgl',
'ckeditor',
'recurrence',
'haystack',
'aldryn_common',
'aldryn_boilerplates',
'aldryn_video',
'aldryn_search',
'aldryn_bootstrap3',
'standard_form',
'debug_toolbar',
'spurl',
'leaflet',
'djgeojson',
'adminsortable2',
'gunicorn',
'nocaptcha_recaptcha',
'plan']
Installed Middleware:
['debug_toolbar.middleware.DebugToolbarMiddleware',
'cms.middleware.utils.ApphookReloadMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'cms.middleware.user.CurrentUserMiddleware',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.toolbar.ToolbarMiddleware',
'cms.middleware.language.LanguageCookieMiddleware']
Traceback:
File "/home/vincent/venv/cms/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response
149. response = self.process_exception_by_middleware(e, request)
File "/home/vincent/venv/cms/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response
147. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/vincent/venv/cms/lib/python3.4/site-packages/django/contrib/admin/options.py" in wrapper
541. return self.admin_site.admin_view(view)(*args, **kwargs)
File "/home/vincent/venv/cms/lib/python3.4/site-packages/django/utils/decorators.py" in _wrapped_view
149. response = view_func(request, *args, **kwargs)
File "/home/vincent/venv/cms/lib/python3.4/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
57. response = view_func(request, *args, **kwargs)
File "/home/vincent/venv/cms/lib/python3.4/site-packages/django/contrib/admin/sites.py" in inner
244. return view(request, *args, **kwargs)
File "/home/vincent/venv/cms/lib/python3.4/site-packages/django/contrib/admin/options.py" in add_view
1437. return self.changeform_view(request, None, form_url, extra_context)
File "/home/vincent/venv/cms/lib/python3.4/site-packages/django/utils/decorators.py" in _wrapper
67. return bound_func(*args, **kwargs)
File "/home/vincent/venv/cms/lib/python3.4/site-packages/django/utils/decorators.py" in _wrapped_view
149. response = view_func(request, *args, **kwargs)
File "/home/vincent/venv/cms/lib/python3.4/site-packages/django/utils/decorators.py" in bound_func
63. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/usr/lib/python3.4/contextlib.py" in inner
30. return func(*args, **kwds)
File "/home/vincent/venv/cms/lib/python3.4/site-packages/django/contrib/admin/options.py" in changeform_view
1367. ModelForm = self.get_form(request, obj)
File "/home/vincent/venv/cms/lib/python3.4/site-packages/django/contrib/admin/options.py" in get_form
639. return modelform_factory(self.model, **defaults)
File "/home/vincent/venv/cms/lib/python3.4/site-packages/django/forms/models.py" in modelform_factory
545. return type(form)(class_name, (form,), form_class_attrs)
File "/home/vincent/venv/cms/lib/python3.4/site-packages/django/forms/models.py" in __new__
247. opts.field_classes)
File "/home/vincent/venv/cms/lib/python3.4/site-packages/django/forms/models.py" in fields_for_model
176. formfield = formfield_callback(f, **kwargs)
File "/home/vincent/venv/cms/lib/python3.4/site-packages/leaflet/admin.py" in formfield_for_dbfield
42. return db_field.formfield(**kwargs)
File "/home/vincent/venv/cms/lib/python3.4/site-packages/djgeojson/fields.py" in formfield
65. return super(GeoJSONField, self).formfield(**kwargs)
File "/home/vincent/venv/cms/lib/python3.4/site-packages/jsonfield/fields.py" in formfield
46. return super(JSONField, self).formfield(**defaults)
File "/home/vincent/venv/cms/lib/python3.4/site-packages/django/db/models/fields/__init__.py" in formfield
903. return form_class(**defaults)
File "/home/vincent/venv/cms/lib/python3.4/site-packages/jsonfield/forms.py" in __init__
15. super(JSONFormField, self).__init__(*args, **kwargs)
File "/home/vincent/venv/cms/lib/python3.4/site-packages/django/forms/fields.py" in __init__
229. super(CharField, self).__init__(*args, **kwargs)
Exception Type: TypeError at /fr/admin/plan/lieu/add/
Exception Value: __init__() got an unexpected keyword argument 'geom_type' I got this after upgrade django to 1.9 from 1.8, django-leaflet to 0.18 from 0.17 and django-geojson 2.9.0 from 2.8.1 I try the @kevcooper manipulation on django-jsonfield but no success because "jsonfield" don't contain a forms module, django-geojson need both apps for work. Like you see i use django-cms but i think it is not the problem, thats work with it before the upgrade. Thanks |
Fixed this with downgrade django from 1.9.7 to 1.8.13 , jsonfield 1.0.3 to 1.0.0 and django-geojson 2.9.0 to 2.8.1 and this work, and then re-upgrade all to latest and work too.... Don't understand. |
Same issue here... can't fix it by installing the other package... still need to trace the issue. Keep u posted. |
After reading http://fle.github.io/easy-webmapping-with-django-leaflet-and-django-geojson.html i assumed(!) that just adding django-geojson and django-leaflet to the requirements / installing them with pip is enough. What i forgot is to install them properly. After reading through the manuals: It's mentioned that you must add them to INSTALLED_APPS too, and you indeed need jsonfield, not django-jsonfield. Obvious :) After that's done it works like a charm. (Do note that these fields do not store raw geojson: they store their own structure which may not be compatible with the data you're processing now. However: that leads to different errors and different challenges :)) |
I’m not using it anymore, so I can't test the original issue. You can close it at will. |
It would be nice to propose a fix on the documentation to make it «obvious» |
Hî!
I encountered a bug using Python 3.4 and Django 1.8, attempting to use the admin.
my_app.admin.py:
my_app.models.py:
Traceback:
I was able to work around this issue by commenting the formfield() method, in fields.py:63:
It seems the geom_type is correctly taken in the FormField. So, what is the point of this method?
The text was updated successfully, but these errors were encountered: