Opened 14 years ago

Closed 14 years ago

#14316 closed (duplicate)

GeoModelAdmin forms have error on GeometryField

Reported by: Paul Winkler Owned by: nobody
Component: GIS Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Given a model like this:

from django.contrib.gis.db import models

class Foo(models.Model):
    location = models.GeometryField(blank=True, null=True)

And an Admin class like this:

from django.contrib.gis import admin

class OSMModelAdmin(admin.GeoModelAdmin):
    pass

admin.site.register(Foo, FooAdmin)

... I get this error in firebug when looking at the admin view for a Foo instance:

controls[i] is undefined
[Break on this error] this.controls=this.controls.concat(con...].panel_div.title=controls[i].title;} 

It looks to me like this happens because of the line geodjango_location.controls = [nav, draw_ctl, mod];
where draw_ctl is undefined unless either .is_point, .is_linestring, or .is_polygon is true;
and if the field is a generic GeometryField, i.e. able to save any kind of geometry, then none of those is true.
So draw_ctl is undefined and the following call to addControls() fails because of that.

I'm not sure what *should* be done in the UI in this case, but throwing an error isn't great.

Well, maybe the UI should allow the user to choose whether to add a point, linestring, or collection, but that'd take some work.

Change History (1)

comment:1 by Paul Winkler, 14 years ago

Resolution: duplicate
Status: newclosed

doh. just found #9806.
The most recent patch (http://code.djangoproject.com/attachment/ticket/9806/9806.3.diff) works for me against Django 1.2.3.

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