Reputation: 1091
I have a strange situation and have no idea how to find the problem.
I have created a blueprint like this
reportjobsmod = Blueprint('jobreports', __name__, url_prefix='/jobreports', template_folder='templates')
And I have created routes like the following in the views.py
file
@reportjobsmod.route('/crc_booksdue/', methods=['GET','POST'])
def crc_booksdue():
Then I use
action="{{ url_for('jobreports.crc_booksdue') }}"
in the template.
This all works fine with a couple more routes.
However, when I try to add the following route to my views.py
@reportjobsmod.route('/job_status/', methods=['GET','POST'])
def jobs_status():
and enter
action="{{ url_for('jobreports.job_status') }}"
in the template I get routing.BuildError
I tried changing the name of the route, I replaced it with an existing route (which worked ok in the template)
I printed out app.url_map and the jobreports.job_status is there along with the other routes.
What do I try next?
Upvotes: 2
Views: 747
Reputation: 5682
Take a look at the url_for
documentation:
Generates a URL to the given endpoint with the method provided.
That's the method from your app, as spelled in the app.
Your error is from
The url_for function results in a BuildError when the current app does not have a URL for the given endpoint and values.
The endpoint
parameter for the function states
endpoint – the endpoint of the URL (name of the function)
In the quickstart, there's also a mention:
To build a URL to a specific function you can use the url_for() function. It accepts the name of the function as first argument [...]
Upvotes: 1