Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text Field not showing when using list_editable on django admin

I am using django-1.7 for my project. I am trying to use the list_editable option of the Django admin to edit one field of multiple objects at once. Here is my code:

class CustomForm(forms.ModelForm):
    name = forms.CharField(max_length=100, required=False)

class CustomAdmin(admin.ModelAdmin):
    form = CustomForm
    change_form = CustomForm
    list_display = ('status', )
    list_editable = ('status',)  

admin.site.register(Custom, CustmAdmin)

I am only able to see a save button on the list view page of this model. I can't find any text field for the status to enter text to update it on various objects of this model.

Any help would be appreciated

enter image description here

like image 585
Sarfraz Ahmad Avatar asked Dec 30 '25 09:12

Sarfraz Ahmad


1 Answers

The problem is that you only have one item in list_display, and Django is using that item to link to the change view for that item.

You can either add another field to the beginning of list_display, and then Django will automatically link that field.

class CustomAdmin(admin.ModelAdmin):
    list_display = ('other_field', 'status')
    list_editable = ('status',)  

Or you can set list_display_links to make a different field linkable. You can also do list_display_links = None, but then you won't be able to click through to edit the item.

like image 174
Alasdair Avatar answered Jan 02 '26 01:01

Alasdair