Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'RegistrationForm' object has no attribute 'save' #68

Open
tauseedzaman opened this issue Jul 9, 2023 · 2 comments
Open

'RegistrationForm' object has no attribute 'save' #68

tauseedzaman opened this issue Jul 9, 2023 · 2 comments

Comments

@tauseedzaman
Copy link

HI,
i followed the instruction given for this package on https://pypi.org/ but I am getting this error.
this is view.py
image
and this is the error
image

is it something wrong in my app or is it an issue in the package

@tauseedzaman
Copy link
Author

`class RegistrationForm(forms.Form):

username = forms.CharField(max_length=150, widget=forms.TextInput(attrs={"class": "form-control form-control-lg"}))
email = forms.EmailField(widget=forms.EmailInput(attrs={"class": "form-control form-control-lg"}))
password = forms.CharField(widget=forms.PasswordInput(attrs={"class": "form-control form-control-lg"}))
confirm_password = forms.CharField(widget=forms.PasswordInput(attrs={"class": "form-control form-control-lg"}))

def clean_username(self):
    username = self.cleaned_data['username']
    # Add your validation logic for the username
    if User.objects.filter(username=username).exists():
        raise forms.ValidationError("Username is already taken.")
    return username

def clean_email(self):
    email = self.cleaned_data['email']
    # Add your validation logic for the email
    if User.objects.filter(email=email).exists():
        raise forms.ValidationError("Email is already registered.")
    return email

def clean(self):
    cleaned_data = super().clean()
    password = cleaned_data.get('password')
    confirm_password = cleaned_data.get('confirm_password')
    # Add your validation logic for the password fields
    if password and confirm_password and password != confirm_password:
        raise forms.ValidationError("Passwords do not match.")

`

this is RegistrationForm

@sebastianhaas
Copy link
Contributor

sebastianhaas commented Nov 5, 2023

@tauseedzaman I believe the issue is

def send_verification_link(self, request, inactive_user=None, form=None):
if form:
inactive_user = form.save(commit=False)
inactive_user.is_active = False
inactive_user.save()
which is called in
return _VerifyEmail().send_verification_link(request, form)
. It was changed with a960b57.

To me, this is clearly a bug, since the public API was not updated to reflect the changed internal method parameters. This should be changed to a named parameter form=form instead, which resolves the issue you are experiencing.

@foo290 would you be willing to accept a PR on this?

sebastianhaas added a commit to sebastianhaas/Django-Verify-Email that referenced this issue Nov 8, 2023
The signature of send_verification_link was changed in a960b57.
However, the corresponding invocation of this method in the documented public API was left unchanged, which introduced a bug reported in foo290#68.
sebastianhaas added a commit to sebastianhaas/Django-Verify-Email that referenced this issue Nov 8, 2023
The signature of send_verification_link was changed in a960b57.
However, the corresponding invocation of this method in the documented public API was left unchanged, which introduced a bug reported in foo290#68.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants