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/0017_alter_titlemeta_extended_object.py b/djangocms_page_meta/migrations/0017_alter_titlemeta_extended_object.py new file mode 100644 index 0000000..0b6b0a9 --- /dev/null +++ b/djangocms_page_meta/migrations/0017_alter_titlemeta_extended_object.py @@ -0,0 +1,20 @@ +# Generated by Django 4.2.16 on 2024-11-06 20:52 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('cms', '0037_alter_cmsplugin_id_alter_globalpagepermission_id_and_more'), + ('djangocms_page_meta', '0016_auto_20230830_1007'), + ] + + operations = [ + migrations.AlterField( + model_name='titlemeta', + name='extended_object', + field=models.OneToOneField(editable=False, on_delete=django.db.models.deletion.CASCADE, to='cms.pagecontent'), + ), + ] 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)