Report an error to display 'url_args' is undefined' in the flask jinja2 template

this is my flask code:

< H1 > coding=utf-8 < / H1 >

from flask import render_template, request,flash, redirect, url_for,current_app,abort
from. Import main
from.. import db
from.. models import Post, Comment
from flask_login import login_required, current_user
from .forms import CommentForm, PostForm
from flask_babel import gettext as _

@ main.errorhandler
def page_not_found (error):

return render_template("404.html"), 404

@ main.route ("/")
def index ():

page_index = request.args.get("page", 1, type=int)

query = Post.query.order_by(Post.created.desc())

pagination = query.paginate(page_index, per_page=20,error_out=False)

posts = pagination.items

return render_template("index.html",
                       title=_(u"Lee"),
                       posts=posts,
                       pagination=pagination)

this is my template code:
{% extends" bootstrap/base.html"%}
{% block title%} {{title}} {% endblock%}
{% block head%}

{{ super() }}
{% include ["includes/_head.html", "includes/_metas.html"] %}

{% endblock%}
{% block styles%}

{{ super() }}
<link rel="stylesheet"
      href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.5/cerulean/bootstrap.min.css ">

{% endblock%}
{% block navbar%}

{-sharp { nav.top.render() }} -sharp}
{% include "includes/_navbar.html" %}

{endblock}

{block content}

{% block header %}
    <header>
        <div class="page-header">
            <div class="container">
                <h1>{{ title }}</h1>
            </div>
        </div>
    </header>
{% endblock %}
{% block page_body %}
{% endblock %}

{endblock}

this is my error display:

clipboard.png

clipboard.png

clipboard.png

is it the wrong way I use it? Please answer

Feb.28,2021

The

problem has been solved. The error is an error in the use of pagination in index.html. The original code is
{% if pagination%}

.
        {{ render_pagination(pagination) }}
    {% endif %}

has been corrected:
{% if pagination%}
< div class= "pagination" >

{{ macros.pagination_widget(pagination,'.index') }}

< / div >
{% endif%}

at the same time, the macros macro paging template is modified: {- sharp% marco input (name,value='',type='text',size=20)%-sharp}
{% macro pagination_widget (pagination, endpoint, fragment='')%}

<!--input type="{{ type }}"
       name="{{ name }}"
       value="{{ value }}"
       size="{{ size }}"
       /-->

< ul class= "pagination" >

<li{% if not pagination.has_prev %} class="disabled"{% endif %}>
    <a href="{% if pagination.has_prev %}{{ url_for(endpoint, page=pagination.prev_num, **kwargs) }}{{ fragment }}{% else %}-sharp{% endif %}">
        
    </a>
</li>
{% for p in pagination.iter_pages() %}
    {% if p %}
        {% if p == pagination.page %}
        <li class="active">
            <a href="{{ url_for(endpoint, page = p, **kwargs) }}{{ fragment }}">{{ p }}</a>
        </li>
        {% else %}
        <li>
            <a href="{{ url_for(endpoint, page = p, **kwargs) }}{{ fragment }}">{{ p }}</a>
        </li>
        {% endif %}
    {% else %}
    <li class="disabled"><a href="-sharp"></a></li>
    {% endif %}
{% endfor %}
<li{% if not pagination.has_next %} class="disabled"{% endif %}>
    <a href="{% if pagination.has_next %}{{ url_for(endpoint, page=pagination.next_num, **kwargs) }}{{ fragment }}{% else %}-sharp{% endif %}">
        
    </a>
</li>

{% endmacro%}
comments out the original content

Menu