Reputation: 2148
I have a view that is defined like such:
@views.route('/issues')
def show_view():
action = request.args.get('action')
method = getattr(process_routes, action)
return method(request.args)
in my process_routes module, I would like to call this method, and pass query string values. I have the following code:
return redirect(url_for('views.show_view', action='create_or_update_success'))
I have a function in process_routes named create_or_update_success
I am getting
BuildError: ('views.show_view', {'action': 'create_or_update_success'}, None)
views is a blueprint. I can successfully call
/issues?action=create_or_update_success
In my browser.
What am I doing wrong?
Upvotes: 3
Views: 1535
Reputation: 1121914
The first part, views.
, has to reflect the first argument you give to your Blueprint()
object exactly.
Don't be tempted to set that first argument to __name__
, as that is likely to contain the full path of the module when inside a package. In your case I suspect that to be some_package.views
rather than just views
.
Use a string literal for the Blueprint()
first argument instead:
views_blueprint = Blueprint('views', __name__)
so you can refer to url_for('views.show_view')
without getting build errors.
Upvotes: 1