Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8818257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:04:01+00:00 2026-06-14T05:04:01+00:00

I am building a simple extension for flask and have a problem with the

  • 0

I am building a simple extension for flask and have a problem with the url_for function not being able to build the urls within the extension.

Can somebody help me figure out what I am missing here?

I simplified the code to demonstrate the issue (all of the url_for calls raise a werkzeug BuildError exception):

import flask
import flask.views

import logging
logging.basicConfig(level=logging.DEBUG)

class MyFlaskExt(object):
    def __init__(self, app=None):
        if app is not None:
            self.init_app(app)

    def init_app(self, app):
        self.blueprint = flask.Blueprint('myext', __name__, static_folder='static', template_folder='templates')
        self.blueprint.add_url_rule('/', view_func=RootView.as_view('root'), endpoint='root')
        self.blueprint.add_url_rule('/var/<somevar>', view_func=VarView.as_view('var'), endpoint='var')
        self.blueprint.add_url_rule('/novar', view_func=NoVarView.as_view('novar'), endpoint='novar')
        app.register_blueprint(self.blueprint)


class RootView(flask.views.View):
    def dispatch_request(self):
        logging.debug(flask.url_for('novar'))
        logging.debug(flask.url_for('novar', _external=True))
        return flask.redirect(flask.url_for('var', somevar='test'))

class VarView(flask.views.View):
    def dispatch_request(self, somevar):
        return "SUCCESS! ({})".format(somevar)

class NoVarView(flask.views.View):
    def dispatch_request(self):
        return "SUCCESS!"

if __name__ == '__main__':
    app = flask.Flask(__name__)
    app.debug = True
    my_ext = MyFlaskExt()
    my_ext.init_app(app)
    logging.debug(app.url_map)
    app.run()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:04:02+00:00Added an answer on June 14, 2026 at 5:04 am

    Blueprint endpoints are registered under the name of the Blueprint. If I remember correctly you will either need to prepend your url_for calls with “.” (if they will all be operating under the same blueprint) or use the full name:

    def dispatch_request(self):
        logging.debug(flask.url_for('.novar'))
        logging.debug(flask.url_for('.novar', _external=True))
        return flask.redirect(flask.url_for('.var', somevar='test'))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently building a Safari Extension. I have a simple popover page with
Im building a simple chat client which is only supposed to be able to
I'm building a simple availability calendar with PHP and MySQL. I have a table
I'm building a simple contact form for a website. It does not connect to
I have a very simple code, that just draws a building, I want to
I am building an extension where I want to be able to add a
I am building my first chrome extension, for that I want to have some
I'm building a simple C extension for a Ruby module, and I'm running into
I am building a chrome extension which will only be available for people within
I am building a simple Firefox extension using the Add-on SDK 1.0. Scouring the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.