On the Django website this sample code is given:
>>> class RestrictedArticleForm(EnhancedArticleForm):
... class Meta(ArticleForm.Meta):
... exclude = ('body',)
My understanding of this is that there's a modelform called EnhancedArticleForm (or ArticleForm and EnhancedArticleForm) and that this should exclude the body field from the form when it's rendered. My code looks like this:
class EditUserForm(UserForm):
class Meta(UserForm.Meta):
exclude = ('username',)
I don't want the user to be able to change their username obviously. But with this code in place, all it does is make the username field the last field to be displayed. It doesn't actually exclude it. Am I missing something obvious?
Edit:
Apparently this is because of a bug in django. I'm trying to overwrite init like so but the form doesn't show up. I think it's because I maybe did this wrong:
class EditUserForm(UserForm):
def __init__(self,instance):
UserForm.__init__(self,instance)
del self.fields['username']