Code

Opened 6 years ago

Closed 6 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: UI/UX:

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.

Attachments (0)

Change History (3)

comment:1 Changed 6 years ago by jbronn

  • Keywords gis geometry admin list_display added
  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to jbronn
  • Patch needs improvement unset
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 6 years ago by jbronn

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

comment:3 Changed 6 years ago by jbronn

  • Resolution set to invalid
  • Status changed from assigned to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.