I'm using the Django admin site with some readonly fields on records:
class BookAdmin(admin.ModelAdmin):
fieldsets = [
(None, {'fields': ['title', 'library_id', 'is_missing', \
'transactions_all_time']}),
]
readonly_fields = ['transactions_all_time',]
list_display = ('library_id', 'author', 'title')
This works great when editing records - the transactions_all_time field is read-only, just as I want.
However, when adding new records it behaves a bit oddly. I get a read-only section at the bottom of the page, which I can't edit and which is irrelevant at this point.
It would be much better if this field was not present at all when adding new records.
Is there any Django option for not displaying read-only fields while adding a new record? I know I can hack the CSS on add_form.html to hide it, but is there a better way?
Thanks.