플라스크 탬플릿 sytax오류

question_detail tample의 전체 코드입니다.
교재내용을 하나하나 따라하면서 작성한 내용인데 3-10. 게시물 수정&삭제 기능 추가하기 과정까지는 다 진행했었습니다.
3-11 댓글기능 추가하기를 진행하기 앞서 실행해서 3-10까지의 결과를 재확인하는 과정에서 아래 오류가 발생했습니다.

jinja2.exceptions.TemplateSyntaxError
jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'endblock'. You probably made a nesting mistake. Jinja is expecting this tag, but currently looking for 'elif' or 'else' or 'endif'. The innermost block that needs to be closed is 'if'.

Traceback (most recent call last)
File "C:\venvs\myproject\Lib\site-packages\flask\app.py", line 2091, in call
return self.wsgi_app(environ, start_response)
File "C:\venvs\myproject\Lib\site-packages\flask\app.py", line 2076, in wsgi_app
response = self.handle_exception(e)
File "C:\venvs\myproject\Lib\site-packages\flask\app.py", line 2073, in wsgi_app
response = self.full_dispatch_request()
File "C:\venvs\myproject\Lib\site-packages\flask\app.py", line 1518, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\venvs\myproject\Lib\site-packages\flask\app.py", line 1516, in full_dispatch_request
rv = self.dispatch_request()
File "C:\venvs\myproject\Lib\site-packages\flask\app.py", line 1502, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
File "C:\projects\myproject\pybo\views\question_views.py", line 28, in detail
return render_template('question/question_detail.html', question=question, form=form)
File "C:\venvs\myproject\Lib\site-packages\flask\templating.py", line 148, in render_template
ctx.app.jinja_env.get_or_select_template(template_name_or_list),
File "C:\venvs\myproject\Lib\site-packages\jinja2\environment.py", line 1068, in get_or_select_template
return self.get_template(template_name_or_list, parent, globals)
File "C:\venvs\myproject\Lib\site-packages\jinja2\environment.py", line 997, in get_template
return self._load_template(name, globals)
File "C:\venvs\myproject\Lib\site-packages\jinja2\environment.py", line 958, in _load_template
template = self.loader.load(self, name, self.make_globals(globals))
File "C:\venvs\myproject\Lib\site-packages\jinja2\loaders.py", line 137, in load
code = environment.compile(source, name, filename)
File "C:\venvs\myproject\Lib\site-packages\jinja2\environment.py", line 757, in compile
self.handle_exception(source=source_hint)
File "C:\venvs\myproject\Lib\site-packages\jinja2\environment.py", line 925, in handle_exception
raise rewrite_traceback_stack(source=source)
File "C:\projects\myproject\pybo\templates\question\question_detail.html", line 75, in template
{% endblock %}
jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'endblock'. You probably made a nesting mistake. Jinja is expecting this tag, but currently looking for 'elif' or 'else' or 'endif'. The innermost block that needs to be closed is 'if'.
The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error.
To switch between the interactive traceback and the plaintext one, you can click on the "Traceback" headline. From the text traceback you can also create a paste of it. For code execution mouse-over the frame you want to debug and click on the console icon on the right side.

You can execute arbitrary Python code in the stack frames and there are some extra helpers available for introspection:

dump() shows all variables in the frame
dump(obj) dumps all that's known about the object
Brought to you by DON'T PANIC, your friendly Werkzeug powered traceback interpreter.


{% extends 'base.html' %}
{% block content %}
<div class="container my-3">
    <h2 class="border-bottom my-3 py-2">{{ question.subject }}</h2>
    <div class="card my-3">
        <div class="card-body">
            <div class="card-text" style="white-space: pre-line;">{{ question.content }}</div>
            <div class="d-flex justify-content-end">
                {% if question.modify_date %}
                <div class="badge badge-light p-2 text-left mx-3">
                    <div class="mb-2">modified at</div>
                    <div>{{ question.create_date|datetime }}</div>
                </div>
            </div>
            {% if g.user == question.user %}
            <div class="my-3">
                <a href="{{ url_for('question.modify', question_id=question.id) }}"
                   class="btn btn-sm btn-outline-secondary">수정</a>
                <a href="#" class=" delete btn btn-sm btn-outline-secondary"
                   data-uri="{{ url_for('question.delete', question_id=question.id) }}">삭제</a>
            </div>
            {% endif %}
        </div>
    </div>
    <h5 class="border-bottom my-3 py-2">{{ question.answer_set|length }}개의 답변이 있습니다.</h5>
    {% for answer in question.answer_set %}
    <div class="card my-3">
        <div class="card-body">
            <div class="card-text" style="white-space: pre-line;">{{ answer.content }}</div>
            <div class="d-flex justify-content-end">
                {% if answer.modify_date %}
                <div class="badge badge-light p-2 text-left mx-3">
                    <div class="mb-2">modified at</div>
                    <div>{{ answer.modify_date|datetime }}</div>
                </div>
                {% endif %}
                <div class="badge badge-light p-2 text-left">
                    <div class="mb-2">{{ answer.user.username }}</div>
                    <div>{{ answer.create_date|datetime }}</div>
                </div>
            </div>
            {% if g.user == answer.user %}
            <div class="my-3">
                <a href="{{ url_for('answer.modify', answer_id=answer.id) }}"
                   class="btn btn-sm btn-outline-secondary">수정</a>
                <a href="#" class="delete btn btn-sm btn-outline-secondary"
                   data-uri="{{ url_for('answer.delete', answer_id=answer.id) }}">삭제</a>
            </div>
            {% endif %}
        </div>
    </div>
    {% endfor %}
    <form action="{{ url_for('answer.create', question_id=question.id) }}" method="post" class="my-3">
        {{ form.csrf_token }}
        <!-- 오류표시 Start -->
        {% for field, errors in form.errors.items() %}
        <div class="alert alert-danger" role="alert">
            <strong>{{ form[field].label }}</strong>: {{ ', '.join(errors) }}
        </div>
        {% endfor %}
        <!-- 오류표시 End -->
        <div class="form-group">
            <textarea {% if not g.user %}disabled{% endif %}
                      name="content" id="content" class="form-control" rows="10"></textarea>
        </div>
        <input type="submit" value="답변등록" class="btn btn-primary">
    </form>
</div>
{% endblock %}
{% block script %} <!-- 질문템플릿에 삭제 알림 창 기능 추가 -->
<script type='text/javascript'>
$(document).ready(function(){
    $(".delete").on('click', function() {
        if (confirm("정말로 삭제하시겠습니까?")) {
            location.href = $(this).data('uri');
        }
    });
});
</script>
{% endblock %}

김이호 1241

M 2021년 11월 21일 10:33 오전

목록으로
1개의 답변이 있습니다. 1 / 1 Page
{% if question.modify_date %}

의 닫는 태그가 안보이는것 같네요.

박응용

2021년 11월 21일 10:42 오전