I'm stuck with the RegexValidator Class.
I'm trying to allow input of some defined HTML(p, ul, li) tags in a Character Field. The following Regex does exactly what I need but I'm having difficulty implementing it.
<\/?(?!p|ul|li)[^/>]*>
I'm trying to implment it into my Django model in the following way:
description = models.CharField(max_length = 255, validators=[
RegexValidator(
regex = r'<\/?(?!p|ul|li)[^/>]*>',
message = 'Disallowed Tags',
code = 'DISALLOWED_TAGS',
),
],
)
I'm using Django 1.6. When I implement the above code, it seems that all form submissions (Using Admin Interface) fail validation.
Any ideas?
Thanks
Do your own validator and if the regexp matches throw an error since it shouldn't be allowed.
here more info about validator.