# 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



UserModel = get_user_model()


class UserSerializer(serializers.ModelSerializer):

    class Meta:
        model = UserModel
        fields = ('id', 'first_name', 'last_name', 'email')


class TagSerializer(serializers.ModelSerializer):

    class Meta:
        model = Tag
        fields = ('id', 'text',)

    def create(self, validated_data):

# 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




UserModel = get_user_model()


class UserSerializer(serializers.ModelSerializer):

    class Meta:
        model = UserModel
        fields = ('id', 'first_name', 'last_name', 'email')


class TagSerializer(serializers.ModelSerializer):

    class Meta:
        model = Tag
        fields = ('id', 'text',)

    def create(self, validated_data):

        tag = Tag.objects.filter(**validated_data).first()