python 3.x - Django Allauth replace labels -
i have following form account_signup_form_class
pointing to
class signupform(forms.form): def __init__(self, *args, **kwargs): super(signupform, self).__init__(*args, **kwargs) field_name in self.fields.keys(): print(field_name, self.fields[field_name].label)
i'm trying replace labels each of following fields: username
, email
, password1
, password2
. when form initiated, following printed.
username username email none
but rendered form in browsers shows of fields labels
username* e-mail* password* password (again)*
why username
, email
being printed, , why email
field label none
yet shows fine when rendered.
how able change labels of 4 fields?
you can't on form that's set on account_signup_form_class
. form used base class signupform allauth. can't change field because doesn't exist on form (only on subclass). want have subclass signupform django allauth , use real signup form can set this:
# on settings account_forms = {'signup': 'path.to.custom.singup.form'}
the custom signup form must inherit django allauth singup form this:
from allauth.account.forms import signupform class customsignupform(signupform): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # here can change fields self.fields['email'] = forms.emailfield(label='custom label')
wiki
Comments
Post a Comment