I have a form with several fields that I would like to show to the user but prevent them from editing (should not be an edit box).
My form class looks like this and I'm using the fields meta to have them automatically defined. I'm looking to prevent user from changing their username and email after registration.
class UserEditForm(forms.ModelForm):
class Meta:
model = User
fields = ('username', 'first_name', 'last_name', 'email', 'password')
The question In a Django form, how do I make a field readonly (or disabled) so that it cannot be edited? doesn't provide an answer to what to do if the fields are defined automatically using meta.
I've tried
disabled = ('username', 'email',)
And a few other options but nothing seems to work. I'm looking to prevent someone from also changing the form and submitting it (and the data getting changed) as the previous question suggested can be done.
[Edit]: Using Django 1.11