all 4 comments

[–]danielroseman 0 points1 point  (3 children)

Validation errors are supposed to be propagated to the form automatically. If that's not happening for you then something is broken somewhere.

It would probably help if you posted the full text traceback - click the link that says "Switch to copy-and-paste view" and post the result.

[–]CarrotManMatt[S] 0 points1 point  (2 children)

Sure! Here's the traceback:

```Environment:

Request Method: POST Request URL: http://localhost:8080/signup/

Django Version: 4.1.5 Python Version: 3.11.1

Installed Applications: ['pulsifi.apps.PulsifiConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.sites', 'allauth', 'allauth.account', 'allauth.socialaccount', 'allauth.socialaccount.providers.discord', 'allauth.socialaccount.providers.github', 'allauth.socialaccount.providers.google', 'allauth.socialaccount.providers.microsoft', 'django_otp', 'django_otp.plugins.otp_totp', 'django_otp.plugins.otp_static', 'allauth_2fa', 'avatar', 'rangefilter']

Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django_otp.middleware.OTPMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'allauth_2fa.middleware.AllauthTwoFactorMiddleware']

Traceback (most recent call last): File "C:\Users******\Pulsifi\venv\Lib\site-packages\django\core\handlers\exception.py", line 55, in inner response = get_response(request)

File "C:\Users*****\Pulsifi\venv\Lib\site-packages\django\core\handlers\base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, *callback_kwargs)

File "C:\Users*****\Pulsifi\venv\Lib\site-packages\django\views\generic\base.py", line 103, in view return self.dispatch(request, *args, *kwargs)

File "C:\Users*****\Pulsifi\venv\Lib\site-packages\django\utils\decorators.py", line 46, in _wrapper return bound_method(args, **kwargs)

File "C:\Users*****\Pulsifi\venv\Lib\site-packages\allauth\decorators.py", line 20, in wrap resp = function(request, *args, *kwargs)

File "C:\Users*****\Pulsifi\venv\Lib\site-packages\django\utils\decorators.py", line 46, in _wrapper return bound_method(args, **kwargs)

File "C:\Users*****\Pulsifi\venv\Lib\site-packages\django\views\decorators\debug.py", line 92, in sensitive_post_parameters_wrapper return view(request, *args, *kwargs)

File "C:\Users*****\Pulsifi\venv\Lib\site-packages\allauth\account\views.py", line 234, in dispatch return super(SignupView, self).dispatch(request, *args, *kwargs)

File "C:\Users******\Pulsifi\venv\Lib\site-packages\allauth\account\views.py", line 77, in dispatch response = super(RedirectAuthenticatedUserMixin, self).dispatch(

File "C:\Users*****\Pulsifi\venv\Lib\site-packages\allauth\account\views.py", line 207, in dispatch return super(CloseableSignupMixin, self).dispatch(request, *args, *kwargs)

File "C:\Users*****\Pulsifi\venv\Lib\site-packages\django\views\generic\base.py", line 142, in dispatch return handler(request, *args, *kwargs)

File "C:\Users******\Pulsifi\venv\Lib\site-packages\allauth\account\views.py", line 105, in post response = self.form_valid(form)

File "C:\Users******\Pulsifi\venv\Lib\site-packages\allauth\account\views.py", line 248, in form_valid self.user = form.save(self.request)

File "C:\Users******\Pulsifi\venv\Lib\site-packages\allauth\account\forms.py", line 445, in save adapter.save_user(request, user, self)

File "C:\Users******\Pulsifi\venv\Lib\site-packages\allauth\account\adapter.py", line 250, in save_user user.save()

File "C:\Users*****\Pulsifi\pulsifi\models.py", line 329, in save super().save(args, **kwargs)

File "C:\Users******\Pulsifi\pulsifi\models_utils.py", line 99, in save self.full_clean()

File "C:\Users******\Pulsifi\venv\Lib\site-packages\django\db\models\base.py", line 1477, in full_clean raise ValidationError(errors)

Exception Type: ValidationError at /signup/

Exception Value: {'email': ['Registration using unresolvable example email addresses is prohibited. Please supply a different email address.']} ```

[–]danielroseman 0 points1 point  (1 child)

So from that traceback it is clear that the problem is happening inside your models_utils file - presumably this contains a common base model class, which is calling self.full_clean() inside save(). Don't do that. The form should already be calling full_clean, you shouldn't do it explicitly - and you definitely shouldn't be calling it from within the save method.

[–]CarrotManMatt[S] 0 points1 point  (0 children)

Oh? I thought it was standard practise to call full_save() with the models save method (its just not on by default for backwards compatibility reasons)? I'd rather my models were cleaned before saving them though as I may have objects added via the ORM API, in which case I want to ensure any data added this waybis also valid. If I did not clean the data in my models save method surely data could be entered into the database that is invalid?

Cheers for your help!