Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@wfehr
wfehr / djangocms_migration_helper.py
Last active October 16, 2018 10:45
Helper for migrations in django-cms for plugins which get a model and previously had none.
# anywhere_you_want.py
def create_plugins_from_cmsplugin(new_model_app, new_plugin_model_name,
new_plugin_name, apps=None):
"""
Create plugins for `new_plugin_name` from CMSPlugin-Plugins. This is
necessary if you add a model to a plugin which previously had none.
"""
if apps is None:
from django.apps.registry import apps as dj_apps
apps = dj_apps
@wfehr
wfehr / __init__.py
Created October 17, 2018 07:25
Test-app for django-cms apphooks.
# pass
@wfehr
wfehr / redirect.py
Last active October 30, 2018 09:46
Django middleware to remove trailing slashes
from django import http
from django.conf import settings
from django.core import urlresolvers
from django.core.exceptions import ImproperlyConfigured
from django.utils.deprecation import MiddlewareMixin
class AppendOrRemoveSlashMiddleware(MiddlewareMixin):
"""
This middleware removes a given trailing slash if the resulting path is
@wfehr
wfehr / README
Last active June 27, 2019 05:55
Overview of changed pages for django-cms
This gist provides an overview for page-changes in django-cms.
It prints out the changed plugins etc. for pages.
Note: This is not a 'diff-tool', so you won't see the exact changes, e.g. text-content.
@wfehr
wfehr / migration_filer_deprecation_move.py
Created April 30, 2018 15:54
Migration to move deprecated cmsplugin-*-plugins to the newer djangocms-*-plugins
from django.apps import apps as global_apps
from django.db import migrations
from djangocms_file.models import get_templates as get_file_templates
from djangocms_picture.models import get_templates as get_picture_templates
def forwards_filer_file(apps, schema_editor):
try:
CMSPluginFilerFile = apps.get_model('cmsplugin_filer_file',
'FilerFile')