Django-Verify-Email icon indicating copy to clipboard operation
Django-Verify-Email copied to clipboard

'RegistrationForm' object has no attribute 'save'

Open tauseedzaman opened this issue 2 years ago • 2 comments

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 avatar Jul 09 '23 06:07 tauseedzaman

`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

tauseedzaman avatar Jul 09 '23 06:07 tauseedzaman

@tauseedzaman I believe the issue is https://github.com/foo290/Django-Verify-Email/blob/725e77a1e204aa1139a335083e80f620cedf2154/verify_email/email_handler.py#L31-L38 which is called in https://github.com/foo290/Django-Verify-Email/blob/725e77a1e204aa1139a335083e80f620cedf2154/verify_email/email_handler.py#L98. It was changed with https://github.com/foo290/Django-Verify-Email/commit/a960b57be3cf9ef519e49f48b38f21545816f72f.

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 avatar Nov 05 '23 13:11 sebastianhaas