X-Git-Url: http://git.ithinksw.org/philo.git/blobdiff_plain/cfd7c6155ad83f9ead1f18ff6109cf1dba5835fe..7902f12cf4e054ee4dae904687ac97d5e2f7360a:/philo/models/fields/__init__.py diff --git a/philo/models/fields/__init__.py b/philo/models/fields/__init__.py index efd315f..0003575 100644 --- a/philo/models/fields/__init__.py +++ b/philo/models/fields/__init__.py @@ -8,14 +8,20 @@ from django.utils.translation import ugettext_lazy as _ from philo.forms.fields import JSONFormField from philo.validators import TemplateValidator, json_validator +from philo.forms.widgets import EmbedWidget #from philo.models.fields.entities import * -class TemplateField(models.TextField): +class TemplateField(models.Field): """A :class:`TextField` which is validated with a :class:`.TemplateValidator`. ``allow``, ``disallow``, and ``secure`` will be passed into the validator's construction.""" def __init__(self, allow=None, disallow=None, secure=True, *args, **kwargs): super(TemplateField, self).__init__(*args, **kwargs) self.validators.append(TemplateValidator(allow, disallow, secure)) + + def formfield(self, **kwargs): + defaults = {'widget': EmbedWidget} + defaults.update(kwargs) + return super(TemplateField, self).formfield(**defaults) class JSONDescriptor(object):