Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.contrib.auth.models import User
- from django.contrib.auth.forms import UserCreationForm
- from shop.signals import * #мой сигнал
- class CodeCompare(View):
- def post(self, request):
- body_unicode = request.body.decode('utf-8')
- body_unicode = json.loads(body_unicode)
- email = body_unicode['email']
- phone = body_unicode['phone']
- code = body_unicode['code']
- form = UserCreationForm({"username": email, "password1": phone, "password2":phone })
- if form.is_valid():
- form.save()
- from django.db.models.signals import post_save
- from django.dispatch import receiver
- from django.contrib.auth.models import User
- @receiver(post_save, sender=User)
- def create_customer(sender, instance, created, **kwargs):
- print('Сигнал о том что пользователь создан')
- print(instance.username)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement