admin.py
class CaseNoteInline(admin.TabularInline):
model = CaseNote
form = CaseNoteInlineForm
extra = 1
max_num = 5
readonly_fields = ['User']
def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == 'User':
kwargs['initial'] = request.user.id
return db_field.formfield(**kwargs)
return super(CaseNoteInline, self).formfield_for_foreignkey(
db_field, request, **kwargs
)