GeoModelAdmin forms have error on GeometryField
|Reported by:||Paul Winkler||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
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.