-
-class EntityProxyField(object):
- descriptor_class = None
-
- def __init__(self, *args, **kwargs):
- if self.descriptor_class is None:
- raise NotImplementedError('EntityProxyField subclasses must specify a descriptor_class.')
- self.verbose_name = kwargs.get('verbose_name', None)
- self.help_text = kwargs.get('help_text', None)
-
- def actually_contribute_to_class(self, sender, **kwargs):
- sender._entity_meta.add_proxy_field(self)
- setattr(sender, self.attname, self.descriptor_class(self))
-
- def contribute_to_class(self, cls, name):
- if issubclass(cls, Entity):
- self.name = name
- self.attname = name
- if self.verbose_name is None and name:
- self.verbose_name = name.replace('_', ' ')
- entity_class_prepared.connect(self.actually_contribute_to_class, sender=cls)
- else:
- raise FieldError('%s instances can only be declared on Entity subclasses.' % self.__class__.__name__)
-
- def formfield(self, *args, **kwargs):
- raise NotImplementedError('EntityProxyField subclasses must implement a formfield method.')
-
- def value_from_object(self, obj):
- return getattr(obj, self.attname)
+class TemplateField(models.TextField):
+ def __init__(self, allow=None, disallow=None, secure=True, *args, **kwargs):
+ super(TemplateField, self).__init__(*args, **kwargs)
+ self.validators.append(TemplateValidator(allow, disallow, secure))