diff --git a/aktuelt/models.py b/aktuelt/models.py index f3cfd9e..1811243 100644 --- a/aktuelt/models.py +++ b/aktuelt/models.py @@ -12,6 +12,7 @@ from aktuelt.constants import ContributionTypes from aktuelt.serializers import ( ContributorsSerializer, + NewsBodySerializer, NewsImageSerializer, NewsPageGallerySerializer, NewsPageTagsSerializer, @@ -99,7 +100,7 @@ def schedule(self): api_fields = [ APIField("intro"), - APIField("body"), + APIField("body", serializer=NewsBodySerializer()), # TODO: Replace with prettier (main model based?) serializer pattern? APIField("contributors", serializer=ContributorsSerializer(source="news_page_contributors")), APIField("tags", serializer=NewsPageTagsSerializer()), diff --git a/aktuelt/serializers.py b/aktuelt/serializers.py index 0bc9979..2041165 100644 --- a/aktuelt/serializers.py +++ b/aktuelt/serializers.py @@ -1,5 +1,11 @@ from rest_framework.fields import Field from wagtail.images.api.fields import ImageRenditionField +from wagtail.rich_text import expand_db_html + + +class NewsBodySerializer(Field): + def to_representation(self, value): + return expand_db_html(value) class NewsImageSerializer(Field):