Reputation: 3762
I've been experimenting with the Django admin,
Can someone explain what use readonly_fields have and what difference it makes of just having the field as part of list_display and not on list_editable
Upvotes: 0
Views: 54
Reputation: 31404
The difference is that readonly_fields
applies to the edit view for a single object rather than the list view for all objects.
In the list view, list_editable
controls what can be edited directly from the list view, and list_display
controls what model fields are displayed in the list.
In the individual edit view, readonly_fields
controls which fields are displayed but not editable. All other fields will be editable through the ModelForm
:
By default the admin shows all fields as editable. Any fields in this option will display its data as-is and non-editable; they are also excluded from the
ModelForm
used for creating and editing.
Upvotes: 2