diff --git a/djangocms_rest/serializers/pageserializer.py b/djangocms_rest/serializers/pageserializer.py index 73d306e..8e4e0d7 100644 --- a/djangocms_rest/serializers/pageserializer.py +++ b/djangocms_rest/serializers/pageserializer.py @@ -1,4 +1,5 @@ from django.db import models +from django.urls import reverse from rest_framework import serializers from rest_framework.request import Request @@ -76,7 +77,6 @@ def to_representation(self, page_content): placeholder.slot for placeholder in page_content.page.get_declared_placeholders() ] - print(f"{declared_slots=}") placeholders = [ placeholder for placeholder in page_content.page.get_placeholders(page_content.language) @@ -104,7 +104,13 @@ def to_representation(self, page_content): "absolute_url": page_content.page.get_absolute_url( page_content.language ), - "path": page_content.page.get_path(page_content.language), + "path": f"{self.request.scheme}://{self.request.get_host()}" + reverse( + "cms-page-root", + args=(page_content.language,) + ) if page_content.page.is_home else f"{self.request.scheme}://{self.request.get_host()}" + reverse( + "cms-page-detail", + args=(page_content.language, page_content.page.get_path(page_content.language),) + ), "is_home": page_content.page.is_home, "languages": page_content.page.languages.split(","), } diff --git a/djangocms_rest/serializers/placeholder.py b/djangocms_rest/serializers/placeholder.py index 0099d17..b6afc65 100644 --- a/djangocms_rest/serializers/placeholder.py +++ b/djangocms_rest/serializers/placeholder.py @@ -262,7 +262,7 @@ def to_representation(self, instance): { placeholder.slot: self.host + reverse( - "placeholder-detail", + "cms-placeholder-detail", args=( self.language, content_type_id, diff --git a/djangocms_rest/urls.py b/djangocms_rest/urls.py index 0e6f9fb..f8f6c78 100644 --- a/djangocms_rest/urls.py +++ b/djangocms_rest/urls.py @@ -3,14 +3,14 @@ from . import views urlpatterns = [ - path("", views.LanguageList.as_view(), name="languages-list"), - path("/pages", views.PageList.as_view(), name="pages-list"), - path("/pages/", views.PageDetail.as_view(), name="pages-root"), - path("/pages//", views.PageDetail.as_view()), + path("", views.LanguageList.as_view(), name="language-list"), + path("/pages", views.PageList.as_view(), name="cms-page-list"), + path("/pages/", views.PageDetail.as_view(), name="cms-page-root"), + path("/pages//", views.PageDetail.as_view(), name="cms-page-detail"), path( "/placeholders////", views.PlaceholderDetail.as_view(), - name="placeholder-detail", + name="cms-placeholder-detail", ), ] diff --git a/djangocms_rest/views.py b/djangocms_rest/views.py index ada843d..3d8bffe 100644 --- a/djangocms_rest/views.py +++ b/djangocms_rest/views.py @@ -29,7 +29,7 @@ def get(self, request, format=None): raise Http404 for conf in languages: conf["pages"] = f"{request.scheme}://{request.get_host()}" + reverse( - "pages-list", args=(conf["code"],) + "cms-page-list", args=(conf["code"],) ) return Response(languages)