Exemplo n.º 1
0
    def create(self, validated_data):
        profile_data = validated_data.pop('profile')
        user = User(**validated_data)
        user.save()
        profile.objects.create(user=user, **profile_data)
        return user

        
    def create(self, validate_data):
        profile_data = validate_data.pop("profile")
        raw_password = validate_data.pop("password")
        user = User(**validate_data)
        user.set_password(raw_password)
        user.save()

        UserProfile.objects.create(**profile_data, user=user)
        return user
Exemplo n.º 3
0
    def create(self, validated_data):
        profile_data = validated_data.pop('profile')
        password = validated_data.pop('password')
        user = User(**validated_data)
        user.set_password(password)
        user.save()

        UserProfile.objects.create(user=user, **profile_data)
        return user
Exemplo n.º 4
0
    def create(self, validated_data):
        print(validated_data)
        profile_data = validated_data.pop('profile')
        raw_password = validated_data.pop('password')
        for field in self.REQUIRED_FIELD:
            data = validated_data.get(field)
            if not data:
                self.ERRORS.append(
                    {field: "{field} field is required.".format(field)})

        if self.ERRORS:
            raise serializers.ValidationError(self.ERRORS)

        user = User(**validated_data)
        user.set_password(raw_password)
        user.save()

        UserProfile.objects.create(user=user, **profile_data)
        return user