GIS admin: how to remove individual polygons from a MultiPolygonField?

154 views
Skip to first unread message

Tyler Erickson

unread,
Sep 7, 2008, 8:11:38 AM9/7/08
to Django users
I've been experimenting with the admin interface for a
MultiPolygonField in Django 1.0. (A very useful bit of
functionality!) The OpenLayers map interface loads up correctly, and
I can add and edit multiple polygons, but I can't seem to delete any
of the individual polygons. (The best I can seem to do is delete
vertices of a polygon until I only have 3 vertices left.)

Is there are a way to remove individual polygons from a
MultiPolygonField using the OpenLayers interface?

- Tyler

Here are some snippets of the relevant code...

from django.contrib.gis.db import models
class Target(models.Model):
name = models.CharField(max_length=30)
description = models.CharField(max_length=255)
poly = models.MultiPolygonField()
objects = models.GeoManager()

from django.contrib.gis import admin
class TargetAdmin(admin.GeoModelAdmin):
list_display = ['name']
search_fields = ['name']

admin.site.register(Target, TargetAdmin)

springmeyer

unread,
Sep 8, 2008, 11:30:37 AM9/8/08
to Django users
HI Tyler,

I'm glad the admin interface has been useful to you.

Right now, based on the way the pre-built admin javascript works, you
have the ability to delete all the multipolygons (see the `delete
features`) link which should appear below each OL map in the admin,
and you should have an OL modify feature control available to delete
vertices (and it sounds like you've experimented with this).

It is standard behavior to only be able to delete vertices until you
have 3 remaining. To be able to delete individual multipolygons, a
special editing control will need to be added to delete any selected
polygons. This is a fairly easy thing to do in the OL library and to
do this in your Django admin app you can either override the admin js
by pointing to your own templates and js in the `TargetAdmin` class or
you can file a feature request ticket to have this added
django.contrib.gis.

Dane
Reply all
Reply to author
Forward
0 new messages