Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def create(self, validated_data):
- user_emails_data = validated_data.pop('user_emails')
- chat = CreateChat.objects.create(**validated_data)
- for data in user_emails_data:
- if 'id' in data:
- id = data.pop('id')
- model_user = CustomUser.objects.filter(id=id)
- model_user.update(**data)
- user_email_object = model_user.first()
- print(id, user_email_object)
- else:
- email = data['email']
- password = get_random_string(80)
- user_email_object = CustomUser.objects.create(email=email, password=password)
- chat.user_emails.add(user_email_object)
- chat.save()
- return chat
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement