def __init__(self, *args, **kwargs): kwargs["max_length"] = kwargs.get("max_length", 20) self.markup_default_filter = kwargs.get("default") or MARKUP_DEFAULT_FILTER if self.markup_default_filter: kwargs["default"] = self.markup_default_filter else: kwargs["choices"] = kwargs.get("choices", formatter.choices(MARKUP_CHOICES)) super(MarkupField, self).__init__(*args, **kwargs)
def __init__(self, default=False, formatter=formatter, *args, **kwargs): # Check that the default value is a valid filter if default: if default not in formatter.filter_list: raise ImproperlyConfigured("'%s' is not a registered markup filter. Registered filters are: %s." % (default, ', '.join(formatter.filter_list.iterkeys()))) kwargs.setdefault('default', default) kwargs.setdefault('max_length', 255) kwargs.setdefault('choices', formatter.choices()) kwargs.setdefault('verbose_name', ugettext_lazy('markup')) CharField.__init__(self, *args, **kwargs)