Opened 10 years ago

Closed 10 years ago

#9807 closed (duplicate)

GeometryField crashes contrib.gis.admin

Reported by: ingenieroariel Owned by: nobody
Component: GIS Version: 1.0
Severity: Keywords: admin, gis, GeometryField
Cc: ingenieroariel@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I tried to load this basic model in django.contrib.gis admin and I ended up with a:
Exception Value: Invalid OGR String Type "GEOMETRY"

class SimpleGeo(models.Model):
     geom = models.GeometryField(null=True, blank=True), admin.GeoModelAdmin)

I have inserted two objects, a Point and a Polygon and when using the shell,
I got the correct geom_type in both cases and dir listed the right attributes and methods for each field.

The line that triggers the error is:
'geom_type' : OGRGeomType(db_field._geom), in django/contrib/gis/admin/

I think one of two things should happen:

  • 1. Either the admin defaults to showing a plain text field whenever that happens or
  • 2. (pony alert) we find a way to look for the _geom of the instance and not the class.

Full traceback below:

File "/Library/Python/2.5/site-packages/django/core/handlers/" in get_response
  86.                 response = callback(request, *callback_args, **callback_kwargs)
File "/Library/Python/2.5/site-packages/django/contrib/admin/" in root
  158.                 return self.model_page(request, *url.split('/', 2))
File "/Library/Python/2.5/site-packages/django/views/decorators/" in _wrapped_view_func
  44.         response = view_func(request, *args, **kwargs)
File "/Library/Python/2.5/site-packages/django/contrib/admin/" in model_page
  177.         return admin_obj(request, rest_of_url)
File "/Library/Python/2.5/site-packages/django/contrib/admin/" in __call__
  197.             return self.change_view(request, unquote(url))
File "/Library/Python/2.5/site-packages/django/db/" in _commit_on_success
  238.                 res = func(*args, **kw)
File "/Library/Python/2.5/site-packages/django/contrib/admin/" in change_view
  573.         ModelForm = self.get_form(request, obj)
File "/Library/Python/2.5/site-packages/django/contrib/admin/" in get_form
  277.         return modelform_factory(self.model, **defaults)
File "/Library/Python/2.5/site-packages/django/forms/" in modelform_factory
  318.                               'formfield_callback': formfield_callback})
File "/Library/Python/2.5/site-packages/django/forms/" in __new__
  180.                                       opts.exclude, formfield_callback)
File "/Library/Python/2.5/site-packages/django/forms/" in fields_for_model
  147.         formfield = formfield_callback(f)
File "/Library/Python/2.5/site-packages/django/contrib/gis/admin/" in formfield_for_dbfield
  58.             kwargs['widget'] = self.get_map_widget(db_field)
File "/Library/Python/2.5/site-packages/django/contrib/gis/admin/" in get_map_widget
  76.         class OLMap(self.widget):
File "/Library/Python/2.5/site-packages/django/contrib/gis/admin/" in OLMap
  84.                       'geom_type' : OGRGeomType(db_field._geom),
File "/Library/Python/2.5/site-packages/django/contrib/gis/gdal/" in __init__
  29.                 raise OGRException('Invalid OGR String Type "%s"' % type_input)

Change History (1)

comment:1 Changed 10 years ago by ingenieroariel

Resolution: duplicate
Status: newclosed

Duplicate of #9806

Note: See TracTickets for help on using tickets.
Back to Top