jpwatts / django-positions

A Django field for custom model ordering.
BSD 3-Clause "New" or "Revised" License
284 stars 71 forks source link

Error when registering positionField in django-admin #70

Open havelio opened 4 years ago

havelio commented 4 years ago

i try registering positionField like this

class SomeModelAdmin(admin.ModelAdmin):
    list_display = ['position']

admin.site.register(SomeModel, SomeModelAdmin)

and I get error message:

django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:

ERRORS:
<class 'project.some_models.admin.ModelAdmin'>: (admin.E108) The value of 'list_display[0]' refers to 'position',
which is not a callable, an attribute of 'ModelAdmin', or an attribute or method on 'some_models.SomeModel'.

I handled the error with this:

class SomeModelAdmin(admin.ModelAdmin):
    list_display = ['get_position']

    def get_position(self, obj):
        return obj.position

admin.site.register(SomeModel, SomeModelAdmin)

but it's really confused because it not shown on the documentation it would be nice if the library could handle that error itself