# Path: exampleproject/articles/models.py
# class Article(SingleTenantModelMixin):
#     title = models.CharField(max_length=100)
#     text = models.TextField()
#     tags = models.ManyToManyField('Tag')
#     author = models.ForeignKey(settings.AUTH_USER_MODEL)
# 
#     def __str__(self):
#         return '%s - %s' % (self.title, str(self.author))
# 
# class Tag(MultipleTenantsModelMixin):
#     text = models.CharField(max_length=100)
# 
#     def __str__(self):
#         return self.text


from django.db import transaction
from django.contrib.auth import get_user_model
from rest_framework import serializers
from .models import Article, Tag
            else:
                has_errors = True
                errors.append(serializer.errors)

        if has_errors:
            raise serializers.ValidationError(errors)

        return tags_creators

    def create(self, validated_data):
        tag_creators = validated_data.pop('tags', [])
        create_data = dict(
            validated_data,
            **{'author': self.context['request'].user}
        )
        with transaction.atomic():
            tags = [tag_creator() for tag_creator in tag_creators]
            article = super(ArticleSerializer, self).create(create_data)
            article.tags.set(tags)
            return article

    def update(self, instance, validated_data):
        tag_creators = validated_data.pop('tags', [])
        create_data = dict(
            validated_data,
            **{'author': self.context['request'].user}
        )

        with transaction.atomic():
            tags = [tag_creator() for tag_creator in tag_creators]

# Path: exampleproject/articles/models.py
# class Article(SingleTenantModelMixin):
#     title = models.CharField(max_length=100)
#     text = models.TextField()
#     tags = models.ManyToManyField('Tag')
#     author = models.ForeignKey(settings.AUTH_USER_MODEL)
# 
#     def __str__(self):
#         return '%s - %s' % (self.title, str(self.author))
# 
# class Tag(MultipleTenantsModelMixin):
#     text = models.CharField(max_length=100)
# 
#     def __str__(self):
#         return self.text


# Path: exampleproject/articles/serializers.py
from django.db import transaction
from django.contrib.auth import get_user_model
from rest_framework import serializers
from .models import Article, Tag

            else:
                has_errors = True
                errors.append(serializer.errors)

        if has_errors:
            raise serializers.ValidationError(errors)

        return tags_creators

    def create(self, validated_data):
        tag_creators = validated_data.pop('tags', [])
        create_data = dict(
            validated_data,
            **{'author': self.context['request'].user}
        )
        with transaction.atomic():
            tags = [tag_creator() for tag_creator in tag_creators]
            article = super(ArticleSerializer, self).create(create_data)
            article.tags.set(tags)
            return article

    def update(self, instance, validated_data):
        tag_creators = validated_data.pop('tags', [])
        create_data = dict(
            validated_data,
            **{'author': self.context['request'].user}
        )

        with transaction.atomic():
            tags = [tag_creator() for tag_creator in tag_creators]

            for field_name in Article._meta.get_all_field_names():