You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am experiencing an error for which I can't find an origin, hopefully you may have some insights. Every now and then Django complains that email is not in self.fields[User.USERNAME_FIELD], see below
I can see that it isn't in self.fields but why it isn't is not clear to me. If I restart my app, it works no problem for a while, until when the problem appears again, and the only way to solve it is to restart the app.
My UserCreationForm looks like this
classUserCreationForm(UserCreationForm):
""" A UserCreationForm with optional password inputs. """def__init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["password1"].required=Falseself.fields["password2"].required=False# If one field gets autocompleted but not the other, our 'neither# password or both password' validation will be triggered.self.fields["password1"].widget.attrs["autocomplete"] ="off"self.fields["password2"].widget.attrs["autocomplete"] ="off"defclean_password2(self):
password1=self.cleaned_data.get("password1")
password2=super().clean_password2()
ifbool(password1) ^bool(password2):
raiseforms.ValidationError("Fill out both fields")
returnpassword2
and add_fieldsets is set as follows
add_fieldsets= (
(
None,
{
"description": (
"Enter the new user's name and email address and click Save."" The user will be emailed a link allowing him/her to login to"" the site and set his/her password."
),
"fields": (
"first_name",
"last_name",
"email",
"is_pi",
),
},
),
(
"Password",
{
"description": "Optionally, you may set the user's password here.",
"fields": ("password1", "password2"),
"classes": ("collapse", "collapse-closed"),
},
),
)
Any ideas?
Thank you very much in advance.
The text was updated successfully, but these errors were encountered:
Hello,
I am experiencing an error for which I can't find an origin, hopefully you may have some insights. Every now and then Django complains that
email
is not inself.fields[User.USERNAME_FIELD]
, see belowI can see that it isn't in
self.fields
but why it isn't is not clear to me. If I restart my app, it works no problem for a while, until when the problem appears again, and the only way to solve it is to restart the app.My
UserCreationForm
looks like thisand
add_fieldsets
is set as followsAny ideas?
Thank you very much in advance.
The text was updated successfully, but these errors were encountered: