Flask url_for gives an error while routing in a modular application

I am building a modular application in Flask, and I keep getting a build error if I reference a function in another Blueprint from my current Blueprint, for example. I have a userProfiles.py file

@userP.route('/myProfile/', methods=['GET']) 
def showProfile():
     .....

In another userAccounts.py file, I have

@userA.route('/login/', methods=['GET', 'POST'])
def login():
     .....

And then I have main.py that registers all the drawings and does app.run ()

now I'm trying to execute url_for ('userA.login) from my showProfile function, but I keep getting a - werkzeug.routing.BuildError -. I could not solve this problem, and not solutions on the Internet helped me.

PS The url_for function also does not work in my templates, for some reason it just does not perform the function, I had no choice but to href on the way.

, , , rol_for routing Blueprint

Traceback:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1701, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1689, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1687, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1360, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1358, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1344, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/cevdet/PycharmProjects/FlaskProjects/jobperfect/userProfiles.py", line 126, in showProfile
    else: return redirect(url_for('userA.login'))
  File "/usr/local/lib/python2.7/dist-packages/flask/helpers.py", line 361, in url_for
    return appctx.app.handle_url_build_error(error, endpoint, values)
  File "/usr/local/lib/python2.7/dist-packages/flask/helpers.py", line 354, in url_for
    force_external=external)
  File "/usr/local/lib/python2.7/dist-packages/werkzeug/routing.py", line 1607, in build
    raise BuildError(endpoint, values, method)
BuildError: ('userA.login', {}, None)
127.0.0.1 - - [17/Sep/2012 23:55:12] "GET /myP
+5
1

userA?

url_for() , ( ) , , , .

subapp = Blueprint('profile', __name__)

@subapp.route('/<username>')
def fetch_profile(username):
    pass

, , url_for(), :

url_for('profile.fetch_profile', username=arg)
+7

All Articles