Opened 15 years ago

Closed 15 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

Description

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.site.register(SimpleGeo, 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/options.py#L84

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:

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

Change History (1)

comment:1 by ingenieroariel, 15 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #9806

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