Skip to content
Myr

Docs mention query args now. This fixes #20

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 3149385 · Browse files · 2 files+10 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+10 added−1 removed

  • other:+10 added−1 removed

2 files+10 added−1 removed

modified:docs/quickstart.rst+6 added-1 removed
158 unmodified lines
159`float` like `int` but for floating point values160`path` like the default but also accepts slashes161=========== ===========================================162163.. _url-building:164165URL Building166````````````167168If it can match URLs, can it also generate them? Of course you can. To169build a URL to a specific function you can use the :func:`~flask.url_for`170function. It accepts the name of the function as first argument and a171number of keyword arguments, each corresponding to the variable part of170the URL rule. Here some examples:172the URL rule. Unknown variable parts are appended to the URL as query173parameter. Here some examples:174175>>> from flask import Flask, url_for176>>> app = Flask(__name__)177>>> @app.route('/')
8 unmodified lines
186>>> with app.test_request_context():187... print url_for('index')188... print url_for('login')189... print url_for('profile', username='John Doe')190... print url_for('login', next='/')191... 192/193/login194/login?next=/195/user/John%20Doe196197(This also uses the :meth:`~flask.Flask.test_request_context` method198explained below. It basically tells flask to think we are handling a
443 unmodified lines
modified:flask.py+4 added
143 unmodified lines
144145146def url_for(endpoint, **values):147 """Generates a URL to the given endpoint with the method provided.148 Variable arguments that are unknown to the target endpoint are appended149 to the generated URL as query arguments.150151 For more information, head over to the :ref:`Quickstart <url-building>`.152153 :param endpoint: the endpoint of the URL (name of the function)154 :param values: the variable arguments of the URL rule155 """156 return _request_ctx_stack.top.url_adapter.build(endpoint, values)
695 unmodified lines