X-Git-Url: http://git.ithinksw.org/philo.git/blobdiff_plain/6b1eb578f544517620de8e0abbec391a839a3d0c..4c276c601b86efbba0236eea2bda190bdff48af1:/models/fields.py diff --git a/models/fields.py b/models/fields.py index 50df799..dbf1886 100644 --- a/models/fields.py +++ b/models/fields.py @@ -4,6 +4,7 @@ from django.core.exceptions import FieldError from django.utils.text import capfirst from philo.models.base import Entity from philo.signals import entity_class_prepared +from philo.validators import TemplateValidator __all__ = ('AttributeField', 'RelationshipField') @@ -142,4 +143,18 @@ class RelationshipField(EntityProxyField): def value_from_object(self, obj): relobj = super(RelationshipField, self).value_from_object(obj) - return getattr(relobj, 'pk', None) \ No newline at end of file + return getattr(relobj, 'pk', None) + + +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)) + + +try: + from south.modelsinspector import add_introspection_rules +except ImportError: + pass +else: + add_introspection_rules([], ["^philo\.models\.fields\.TemplateField"]) \ No newline at end of file