Reputation: 33
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
Upvotes: 3
Views: 926
Reputation: 308899
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.
Upvotes: 1