In "flask web Development", the administrator profile editing link reported an error?

problem description

werkzeug.routing.BuildError: Could not build url for endpoint "main.edit_profile_admin" with values [" id"]. Did you mean "main.edit_profile" instead?

the environmental background of the problems and what methods you have tried

Edit the link of the adminstrator user edit_profile in user.html. The parameter id, is passed into the template. There is also an id parameter in the view function, but the error message seems to say that the value id cannot be used as the endpoint to build url?. Searched the Internet for similar questions that did not match my situation

related codes

app/main/view.py (partial)

Edit Profile [Admin]</a>

File "/home/zhang/PycharmProjects/flasky2/venv/lib/python3.5/site-packages/flask/helpers.py", line 356, in url_for

return appctx.app.handle_url_build_error(error, endpoint, values)

File "/home/zhang/PycharmProjects/flasky2/venv/lib/python3.5/site-packages/flask/app.py", line 2061, in handle_url_build_error

reraise(exc_type, exc_value, tb)

File "/home/zhang/PycharmProjects/flasky2/venv/lib/python3.5/site-packages/flask/_compat.py", line 35, in reraise

raise value

File "/home/zhang/PycharmProjects/flasky2/venv/lib/python3.5/site-packages/flask/helpers.py", line 345, in url_for

force_external=external)

File "/home/zhang/PycharmProjects/flasky2/venv/lib/python3.5/site-packages/werkzeug/routing.py", line 1776, in build

raise BuildError(endpoint, values, method, self)

werkzeug.routing.BuildError: Could not build url for endpoint "main.edit_profile_admin" with values ["id"]. Did you mean "main.edit_profile" instead?

       




Oct.15,2021

modify part of app/templates/user.html as follows:

  

you used the custom @ admin_required decorator
maybe your decorators.py is wrong. Check it.

Menu