[Answer]-Django: programatic fields in inlines

1👍

You can do that, but you must also add my_field to your MyModelInline class’s readonly_fields attribute.

fields = ('my_field',)
readonly_fields = ('my_field',)

From the docs:

The fields option, unlike list_display, may only contain names of fields on the model or the form specified by form. It may contain callables only if they are listed in readonly_fields.

If you need the field to be editable, you should be able to do that with a custom form but it takes more work to process it.

Leave a comment