def clean_content(self):
        content = self.cleaned_data.get('content', '')
        if content:
            origin = StringOrigin(content)

            try:
                from django.template.debug import DebugLexer, DebugParser
            except __HOLE__:
                # django.template.debug doesn't exist in Django >= 1.9, so use
                # Template from django.template instead
                from django.template import Template
                # Try to create a Template
                try:
                    template = Template(template_string=origin)
                # This is an error with creating the template
                except Exception as e:
                    self.exc_info = {
                        'message': e.args,
                        'line': e.token.lineno,
                        'name': origin.name,
                    }
                    raise forms.ValidationError('Invalid Django Template')
                # Template has been created; try to parse
                try:
                    template.compile_nodelist()
                # This is an error with parsing
                except Exception as e:
                    # The data we pass to the views is in e.template_debug
                    e.template_debug = template.get_exception_info(e, e.token)
                    self.exc_info = e.template_debug
                    raise forms.ValidationError('Parsing Error')
            else:
                lexer = DebugLexer(content, origin)
                try:
                    parser = DebugParser(lexer.tokenize())
                    parser.parse()
                except Exception as e:
                    self.exc_info = sys.exc_info()
                    if not hasattr(self.exc_info[1], 'django_template_source'):
                        self.exc_info[1].django_template_source = origin, (0, 0)
                    raise forms.ValidationError('Invalid Django Template')
        return content
dataset/ETHPy150Open caktus/django-scribbler/scribbler/forms.py/ScribbleFormMixin.clean_content