<commit_before>from categories.models import Category, Keyword, Subcategory
from rest_framework import serializers


class CategorySerializer(serializers.ModelSerializer):
    class Meta:
        model = Category


class KeywordSerializer(serializers.ModelSerializer):
    class Meta:
        model = Keyword


class SubcategorySerializer(serializers.ModelSerializer):
    class Meta:
        model = Subcategory
        depth = 1<commit_msg>Add more details to category serializers in order to show nested relations<commit_after>from categories.models import Category, Keyword, Subcategory
from rest_framework import serializers


class SubcategoryListSerializer(serializers.ModelSerializer):
    class Meta:
        model = Subcategory
        fields = ('pk', 'name')


class CategorySerializer(serializers.ModelSerializer):
    subcategories = SubcategoryListSerializer(many=True, source='subcategory_set')

    class Meta:
        model = Category
        fields = ('pk', 'name', 'weight', 'comment_required', 'subcategories')


class KeywordSerializer(serializers.ModelSerializer):
    class Meta:
        model = Keyword


class SubcategorySerializer(serializers.ModelSerializer):
    category = CategorySerializer(read_only=True, many=True)

    class Meta:
        model = Subcategory
{'fraction_non_alphanumeric': 0.07275541795665634, 'fraction_numerical': 0.0007739938080495357, 'mean_word_length': 4.3429752066115705, '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': '4093646', 'n_tokens_mistral': 319, 'n_tokens_neox': 308, 'n_words': 89}