django / django-contrib-comments

BSD 3-Clause "New" or "Revised" License
619 stars 197 forks source link

Invalid template syntax in django_comments/templates/comments/preview.html #80

Open maurizi opened 8 years ago

maurizi commented 8 years ago

Posting a comment that causes a validation error, such as a comment longer than 300 characters, is supposed to show the django_comments/templates/comments/preview.html template.

From my testing however, I always get an unhandled error from this line.

TemplateSyntaxError at /comments/post/
Invalid block tag: 'comment_form_target', expected 'endblock'

I am using Django 1.8 and Python 2.7

claudep commented 8 years ago

Weird, because the template is tested. You might try to debug at the point of failure in the traceback to see if this is caused by another problem.

maurizi commented 8 years ago

Here's the full trace:

ERROR:django.request:Internal Server Error: /comments/post/
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 132, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py", line 110, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/http.py", line 45, in inner
    return func(request, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django_comments/views/comments.py", line 103, in post_comment
    "next": data.get("next", next),
  File "/usr/local/lib/python2.7/dist-packages/django/shortcuts.py", line 67, in render
    template_name, context, request=request, using=using)
  File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py", line 96, in render_to_string
    template = select_template(template_name, using=using)
  File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py", line 64, in select_template
    return engine.get_template(template_name, dirs)
  File "/usr/local/lib/python2.7/dist-packages/django/template/backends/django.py", line 30, in get_template
    return Template(self.engine.get_template(template_name, dirs))
  File "/usr/local/lib/python2.7/dist-packages/django/template/engine.py", line 167, in get_template
    template, origin = self.find_template(template_name, dirs)
  File "/usr/local/lib/python2.7/dist-packages/django/template/engine.py", line 141, in find_template
    source, display_name = loader(name, dirs)
  File "/usr/local/lib/python2.7/dist-packages/django/template/loaders/base.py", line 13, in __call__
    return self.load_template(template_name, template_dirs)
  File "/usr/local/lib/python2.7/dist-packages/django/template/loaders/base.py", line 23, in load_template
    template = Template(source, origin, template_name, self.engine)
  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 191, in __init__
    self.nodelist = engine.compile_string(template_string, origin)
  File "/usr/local/lib/python2.7/dist-packages/django/template/engine.py", line 261, in compile_string
    return parser.parse()
  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 342, in parse
    compiled_result = compile_func(self, token)
  File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py", line 210, in do_extends
    nodelist = parser.parse()
  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 342, in parse
    compiled_result = compile_func(self, token)
  File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py", line 184, in do_block
    nodelist = parser.parse(('endblock',))
  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 340, in parse
    self.invalid_block_tag(token, command, parse_until)
  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 395, in invalid_block_tag
    (command, get_text_list(["'%s'" % p for p in parse_until])))
TemplateSyntaxError: Invalid block tag: 'comment_form_target', expected 'endblock'
charettes commented 8 years ago

It's odd, the preview.html template seems to load the comments template tags.

I didn't know {% load %} tags could be used this way, I always assumed they had to be placed at the top of the file.

claudep commented 8 years ago

@maurizi Could you try changing the location of the load tag to see if this makes any difference?

maurizi commented 8 years ago

I moved the {% load comments %} up to the top of the page, but it didn't seem to fix the problem.