Opened 17 years ago

Closed 17 years ago

#6747 closed (invalid)

geometry field does not work in Admin list_display

Reported by: bemclaugh@… Owned by: jbronn
Component: GIS Version: gis
Severity: Keywords: gis geometry admin list_display
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

A geometry field (PointField, PolygonField) does not render in the Admin applications list_display. It does however in the 'Changes' screen of the Admin app.

It seems the sql for the list_display does not include 'AS_TEXT(GeomField)' as it does on the 'Changes' screen

The error returned boils down to:

String or unicode input unrecognized as WKT EWKT, and HEXEWKB.

Change History (3)

comment:1 by jbronn, 17 years ago

Keywords: gis geometry admin list_display added
Owner: changed from nobody to jbronn
Status: newassigned
Triage Stage: UnreviewedAccepted

comment:2 by jbronn, 17 years ago

I've confirmed this is a bug. For now, the workaround is not to use GeometryFields in the admin list_display option.

comment:3 by jbronn, 17 years ago

Resolution: invalid
Status: assignedclosed

I agree this is not the best behavior -- it is a result of overriding the default manager for the model (see #6358). A workaround is to use the little-known manager option on the inner Admin class. Here's an example:

from django.contrib.gis.db import models

class City(models.Model):
    name = models.CharField(max_length=30)
    point = models.PointField()
    objects = models.GeoManager()

    class Meta:
        verbose_name_plural = 'Cities'

    class Admin:
        list_display = ('name', 'point')
        manager = models.GeoManager()

    def __unicode__(self):
        return self.name
Note: See TracTickets for help on using tickets.
Back to Top