From 40f7224553cc011ba93951a9995228c5da9771ef Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Wed, 8 Mar 2017 16:22:03 +0100 Subject: [PATCH] registration: only initialize model fields when registration form prefilling is used (fixes #15610) When prefilling other attributes, it tracebacked on the call to User.__init__(). --- src/authentic2/registration_backend/views.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/authentic2/registration_backend/views.py b/src/authentic2/registration_backend/views.py index 1b03c92..d27bef3 100644 --- a/src/authentic2/registration_backend/views.py +++ b/src/authentic2/registration_backend/views.py @@ -194,7 +194,11 @@ class RegistrationCompletionView(CreateView): if self.token.get('user_id'): kwargs['instance'] = User.objects.get(id=self.token.get('user_id')) else: - kwargs['instance'] = get_user_model()(**attributes) + init_kwargs = {} + for key in ('email', 'first_name', 'last_name', 'ou'): + if key in attributes: + init_kwargs[key] = attributes[key] + kwargs['instance'] = get_user_model()(**init_kwargs) return kwargs -- 2.1.4