librelist archives

« back to archive

ur_for and blueprints.

ur_for and blueprints.

From:
Wawrzek Niewodniczanski
Date:
2013-04-03 @ 08:40
Hi,

I have a blueprint with link to other page in the same app but in
different blueprint. You kindly suggested to use url_for function. But
I have problem with first function argument
(application_name.function_where_you_want_to_point').


In my main file I have:

app = Flask(__name__)
...
app.register_blueprint(volume.
vol)


in blueprint:

vol = Blueprint('volume', __name__)
...

@vol.route('/volume/')
@vol.route('/volume/<volume_name>')
def volume_page(volume_name=None):


What should i put in url_for.

Thanks,
Wawrzek

--
Dr  Wawrzyniec NiewodniczaƄski    or Wawrzek for short
  PhD in Quantum Chemistry  & MSc in Molecular Engineering
   WWW: http://wawrzek.name E-MAIL: jobs@wawrzek.name
      Linux User #177124

Re: [flask] ur_for and blueprints.

From:
greatghoul
Date:
2013-04-03 @ 08:48
url_for('*volume*.volume_page')

while *volume* is the blueprint's name

vol = Blueprint('*volume*', __name__)

On Wed, Apr 3, 2013 at 4:40 PM, Wawrzek Niewodniczanski
<main@wawrzek.name>wrote:

> volume





-- 
 *greatghoul <http://www.g2w.me> - Ask and Learn!*

Re: [flask] ur_for and blueprints.

From:
Wawrzek Niewodniczanski
Date:
2013-04-03 @ 09:47
On 3 April 2013 09:48, greatghoul <greatghoul@gmail.com> wrote:

> url_for('*volume*.volume_page')
>
> while *volume* is the blueprint's name
>
> vol = Blueprint('*volume*', __name__)
>

Great, it works.

I believe, than one of the best method of learning is someone else mistake
and examples.

So for my issue (link from template related to one blueprint pointing onto
another blueprint in the same app), I have changed my template following
way:

-    <a href="volume/{{ volume_name }}"><div class="link">{{ volume_name
}}</div></a>
+    <a href="{{ url_for('volume.volume_page', volume_name=volume_name)
}}"><div class="link">{{ volume_name }}</div></a>
     <div>


Thanks,
Wawrzek
-- 
Dr  Wawrzyniec NiewodniczaƄski    or Wawrzek for short
  PhD in Quantum Chemistry  & MSc in Molecular Engineering
   WWW: http://wawrzek.name E-MAIL: jobs@wawrzek.name
      Linux User #177124