<commit_before>from rest_framework import serializers

from mmkitarchive.models import Item, Category


class ItemDefaultSerializer(serializers.ModelSerializer):

    class Meta:
        model = Item
        fields = ('id', 'name', 'description', 'created', 'author', 'category')


class ItemListSerializer(ItemDefaultSerializer):

    url = serializers.HyperlinkedIdentityField(
        view_name='api:mmkitarchive:item-detail'
    )

    class Meta(ItemDefaultSerializer.Meta):
        fields = ('url', 'id', 'name', 'created', 'category')
        depth = 1


class ItemRetrieveSerializer(ItemDefaultSerializer):

    class Meta(ItemDefaultSerializer.Meta):
        depth = 1


class CategoryDefaultSerializer(serializers.ModelSerializer):

    class Meta:
        model = Category
        fields = ('id', 'name', )<commit_msg>Уточнение по сериализации категории в составе элементов<commit_after>from rest_framework import serializers

from mmkitarchive.models import Item, Category


class CategoryDefaultSerializer(serializers.ModelSerializer):

    class Meta:
        model = Category
        fields = ('id', 'name', )


class ItemDefaultSerializer(serializers.ModelSerializer):

    class Meta:
        model = Item
        fields = ('id', 'name', 'description', 'created', 'author', 'category')


class ItemListSerializer(ItemDefaultSerializer):

    url = serializers.HyperlinkedIdentityField(
        view_name='api:mmkitarchive:item-detail'
    )

    category = CategoryDefaultSerializer(
        read_only=True
    )

    class Meta(ItemDefaultSerializer.Meta):
        fields = ('url', 'id', 'name', 'created', 'category')


class ItemRetrieveSerializer(ItemDefaultSerializer):

    category = CategoryDefaultSerializer(
        read_only=True
    )

    class Meta(ItemDefaultSerializer.Meta):
        fields = ('id', 'name', 'description', 'created', 'author', 'category')
{'fraction_non_alphanumeric': 0.10805084745762712, 'fraction_numerical': 0.001059322033898305, 'mean_word_length': 3.9064935064935065, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1976400', 'n_tokens_mistral': 514, 'n_tokens_neox': 496, 'n_words': 119}