From 5caa79f1990066df954faf0664b0536dc49bebe5 Mon Sep 17 00:00:00 2001 From: "M.Ravi" Date: Thu, 22 Jun 2017 13:40:39 +0530 Subject: [PATCH] Added CustomUser.DoesNotExist error exception --- datacenterlight/views.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/datacenterlight/views.py b/datacenterlight/views.py index b9372514..9708eb24 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -329,8 +329,9 @@ class PaymentOrderView(FormView): vm_template_id = template.get('id', 1) final_price = specs.get('price') token = form.cleaned_data.get('token') - custom_user = CustomUser.objects.get(email=user.get('email')) - if custom_user is None: + try: + custom_user = CustomUser.objects.get(email=user.get('email')) + except CustomUser.DoesNotExist: password = CustomUser.get_random_password() # Register the user, and do not send emails CustomUser.register(user.get('name'),