I'd like a boolean field to be editable in my Django admin's list display. Instead, I have uneditable icons:
My code looks like this:
# Model class Task(models.Model): ... is_finished = models.BooleanField() # Admin list_display = (..., 'is_finished')
I haven't included is_finished
in the readonly_fields
tuple in admin.py
, so I'm surprised that it isn't editable by default. What am I doing wrong?
ModelAdmin.list_editable
is what you need, see its doc here. Below you also have an example:
class TaskAdmin(models.ModelAdmin): list_display = (..., 'is_finished') list_editable = ('is_finished',) # this MUST only contain fields that also are in "list_display" #list_display_links = ('foo', 'bar') # this MUST NOT contain a field in common with "list_editable"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With