Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. from django.contrib.auth.models import User
  2. from django.contrib.auth.forms import UserCreationForm
  3. from shop.signals import * #мой сигнал
  4.  
  5.  
  6. class CodeCompare(View):
  7. def post(self, request):
  8. body_unicode = request.body.decode('utf-8')
  9. body_unicode = json.loads(body_unicode)
  10. email = body_unicode['email']
  11. phone = body_unicode['phone']
  12. code = body_unicode['code']
  13. form = UserCreationForm({"username": email, "password1": phone, "password2":phone })
  14. if form.is_valid():
  15. form.save()
  16.  
  17. from django.db.models.signals import post_save
  18. from django.dispatch import receiver
  19. from django.contrib.auth.models import User
  20.  
  21.  
  22.  
  23. @receiver(post_save, sender=User)
  24. def create_customer(sender, instance, created, **kwargs):
  25. print('Сигнал о том что пользователь создан')
  26. print(instance.username)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement