Permalink
Browse files

added setting for enabling the select2 widget

  • Loading branch information...
1 parent be898df commit c3292ebaec39df6a483ef9d32c7dab0059dd65eb @alesdotio alesdotio committed Mar 15, 2013
Showing with 5 additions and 2 deletions.
  1. +5 −2 stacks/cms_plugins.py
View
7 stacks/cms_plugins.py
@@ -6,13 +6,15 @@
from stacks.fields import StackSearchField
from stacks.models import StackLink, Stack
from cms.plugins.utils import get_plugins
+from django.conf import settings
class StackPlugin(CMSPluginBase):
model = StackLink
name = _("Stack")
render_template = "cms/plugins/stacks.html"
admin_preview = False
+ raw_id_fields = ('stack',)
def render(self, context, instance, placeholder):
# TODO: once we drop 2.3.x support we can just use the "render_plugin" templatetag
@@ -28,8 +30,9 @@ def render(self, context, instance, placeholder):
return context
def formfield_for_dbfield(self, db_field, request=None, **kwargs):
- if db_field.name == "stack":
- return StackSearchField(**kwargs)
+ if getattr(settings, 'DJANGOCMS_STACKS_USE_SELECT2', False):
+ if db_field.name == "stack":
+ return StackSearchField(**kwargs)
return super(StackPlugin, self).formfield_for_dbfield(db_field, request=request, **kwargs)

0 comments on commit c3292eb

Please sign in to comment.