Example #1
0
 def post(self, request, *args, **kwargs):
     form = UserCreateForm(request.POST)
     if form.is_valid():
         password = form.cleaned_data['password']
         User = form.save()
         User.set_password(password)
         User.save()
         msg = "Hello " + User.full_name + " your signup is done and will be authorized by admin within 24 hours via mail/call.Thanks for your patience."
         messages.success(request, msg)
         return HttpResponseRedirect(reverse_lazy('home'))
     return render(request, 'user_auth/user_form.html', {'form': form})
Example #2
0
 def create(self, validated_data):
     user = User(
         mobile_number=validated_data['mobile_number'],
         gender=validated_data['gender'],
         first_name=validated_data['first_name'],
         last_name=validated_data['last_name'],
     )
     user.set_password(validated_data['password'])
     user.save()
     Token.objects.create(user=user)
     return user