문제

I have a model with a PointField from django.contrib.gis.db.models . This somehow doesn't let the admin site show the objects with a nice table of fields and values. Instead it displays one field named after the model name. The values are just a bunch of ' object'. With the name of the model. If I click the object I can edit it fine. It would be nice however to be able to filter and see the field values at the admin/ page itself.

도움이 되었습니까?

해결책

Since PointField does not have a __unicode__ attribute, for the proper name to show up, you can register a new admin model object.

Now, in the admin's list_display,

class PointFieldAdmin(admin.ModelAdmin):
    list_display = ('name', 'field_x', 'field_y', ...)

admin.register(PointField, PointFieldAdmin)

More on admin models registering here

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top