diff --git a/djangocms_page_meta/admin.py b/djangocms_page_meta/admin.py index 8b7a3f8..d75da51 100644 --- a/djangocms_page_meta/admin.py +++ b/djangocms_page_meta/admin.py @@ -1,5 +1,8 @@ from cms.admin.pageadmin import PageAdmin -from cms.extensions import PageExtensionAdmin, TitleExtensionAdmin +try: + from cms.extensions import PageExtensionAdmin, PageContentExtensionAdmin +except ImportError: + from cms.extensions import PageExtensionAdmin, TitleExtensionAdmin as PageContentExtensionAdmin from cms.utils import get_language_from_request from django.conf import settings from django.contrib import admin @@ -68,7 +71,7 @@ def get_model_perms(self, request): @admin.register(TitleMeta) -class TitleMetaAdmin(TitleExtensionAdmin): +class TitleMetaAdmin(PageContentExtensionAdmin): form = TitleMetaAdminForm inlines = (GenericAttributeTitleInline,) diff --git a/djangocms_page_meta/migrations/0016_auto_20230830_1007.py b/djangocms_page_meta/migrations/0016_auto_20230830_1007.py index cbb6770..3daeaee 100644 --- a/djangocms_page_meta/migrations/0016_auto_20230830_1007.py +++ b/djangocms_page_meta/migrations/0016_auto_20230830_1007.py @@ -17,6 +17,9 @@ class Migration(migrations.Migration): dependencies = [ ("djangocms_page_meta", "0015_defaultmetaimage"), ] + run_before = [ + ("cms", "0032_remove_title_to_pagecontent"), + ] operations = [ migrations.RunPython(generate_default_meta_image_singleton, backwards), diff --git a/djangocms_page_meta/models.py b/djangocms_page_meta/models.py index 0b6f6e5..f7e916c 100644 --- a/djangocms_page_meta/models.py +++ b/djangocms_page_meta/models.py @@ -1,8 +1,15 @@ import ast -from cms.extensions import PageExtension, TitleExtension +try: + from cms.models import Page, PageContent + from cms.extensions import PageExtension, PageContentExtension +except ImportError: + from cms.extensions import PageExtension, TitleExtension as PageContentExtension + from cms.models import Page, Title as PageContent + + from cms.extensions.extension_pool import extension_pool -from cms.models import Page, Title + from django.conf import settings from django.core.cache import cache from django.db import models @@ -98,7 +105,7 @@ def robots_list(self): extension_pool.register(PageMeta) -class TitleMeta(TitleExtension): +class TitleMeta(PageContentExtension): image = FilerFileField( null=True, blank=True, @@ -206,7 +213,7 @@ def cleanup_page(sender, instance, **kwargs): cache.delete(key) -@receiver(pre_delete, sender=Title) +@receiver(pre_delete, sender=PageContent) def cleanup_title(sender, instance, **kwargs): key = get_cache_key(instance.page, instance.language) cache.delete(key)