Reputation: 3186
If I explicitly provide a ModelAdmin
for a particular model in Django 1.8 admin, do I have to explicitly set the list_display
member?
If I don't will Django use a default value for it (e.g. all fields except id
in the order defined in the model)?
Upvotes: 1
Views: 426
Reputation: 19902
You do not have to explicitly define list_display
. If you omit it, a single column will be displayed with the str(Model)
value. If you have a __str__
funciton defined for your model (Python 3), that value will be returned, otherwise something like 'MyModel object'. This value will also be a link to your model form.
Therefore, I would say that it is a good practice to define the fields that you want to use.
Please note also that you cannot use fields in list_editable
without them being present in list_display
. This would give a:
SystemCheckError: (admin.E122) The value of 'list_editable[X]' refers to 'Y', which is not contained in 'list_display'.`
Upvotes: 3