Created
October 27, 2010 14:22
-
-
Save gijs/649117 to your computer and use it in GitHub Desktop.
Ugly solution to get jQuery, django-cms, WYMEditor and the Django admin to work together without modifying django-cms' source.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django import forms | |
from django.conf import settings | |
from cms.plugin_pool import plugin_pool | |
from cms.plugins.text.widgets.wymeditor_widget import WYMEditor | |
from cmsapp_news.models import NewsItem | |
class NewsForm(forms.ModelForm): | |
""" | |
Defines a form for News model. | |
""" | |
# This injects the Django Admin's non-minified jQuery into the WYMEditor's | |
# JS include list at runtime. By default, the minified version was used, | |
# which gave errors because jQuery ran in noConflict mode, which in turn | |
# conflicted with WYMEditor requiring the dollar notation to work. | |
WYMEditor.Media.js.insert(0, '/static_media/admin/js/jquery.js') | |
class Meta: | |
model = NewsItem | |
def _get_widget(self): | |
plugins = plugin_pool.get_text_enabled_plugins(placeholder=None, | |
page=None) | |
return WYMEditor(installed_plugins=plugins) | |
def __init__(self, *args, **kwargs): | |
super(NewsForm, self).__init__(*args, **kwargs) | |
widget = self._get_widget() | |
self.fields['article'].widget = widget |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the url request "/add-plugin/" 404 not found