Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make boolean values editable in list_display?

I'd like a boolean field to be editable in my Django admin's list display. Instead, I have uneditable icons:

enter image description here

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?

like image 971
Richard Avatar asked Aug 07 '13 15:08

Richard


1 Answers

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" 
like image 128
Ricola3D Avatar answered Sep 22 '22 17:09

Ricola3D