Ошибка XML ParseError возникает в методе __call__
валидатора, если в RichTextField в Wagtail CMS введен символ '\ n'.
Здесь происходит ошибка
plain_text = ''.join(fromstring(value).itertext())
* 1008 след вызовов TRACEBACK *
from xml.etree.ElementTree import fromstring
from django.core.exceptions import ValidationError
from django.utils.deconstruct import deconstructible
@deconstructible
class ProhibitBlankRichTextValidator:
"""
Validate that the incoming html-string contains plain text characters.
Common usage: Proper RichTextField validation
Reason:
Handling improper RichTextField validation by Wagtail 2.1:
https://github.com/wagtail/wagtail/issues/4549
"""
message = "This field is required."
def __init__(self, message=None):
if message is not None:
self.message = message
def __call__(self, value):
plain_text = ''.join(fromstring(value).itertext()) # Escape html tags
if not plain_text:
raise ValidationError(self.message)