schon/engine/blog/serializers.py
Egor fureunoir Gorbunov eef774c3a3 feat(markdown): integrate markdown rendering and editor support
Replace WYSIWYG editor with Markdown editor across all relevant models and admin fields. Add utilities for rendering and stripping markdown. Adjust serializers, views, and templates to support markdown content. Introduce `PastedImage` model and upload endpoint for handling inline image uploads in markdown.

This change simplifies content formatting while enhancing flexibility with markdown support.
2026-02-27 23:36:51 +03:00

23 lines
603 B
Python

from rest_framework.fields import SerializerMethodField
from rest_framework.serializers import ModelSerializer
from engine.blog.models import Post, PostTag
from engine.core.utils.markdown import render_markdown
class PostTagSerializer(ModelSerializer):
class Meta:
model = PostTag
fields = "__all__"
class PostSerializer(ModelSerializer):
tags = PostTagSerializer(many=True)
content = SerializerMethodField()
class Meta:
model = Post
fields = "__all__"
def get_content(self, obj: Post) -> str:
return render_markdown(obj.content or "")