Docs mention query args now. This fixes #20
This commit is contained in:
parent
31493850de
commit
f1603d33f2
2 changed files with 10 additions and 1 deletions
|
|
@ -160,6 +160,8 @@ The following converters exist:
|
||||||
`path` like the default but also accepts slashes
|
`path` like the default but also accepts slashes
|
||||||
=========== ===========================================
|
=========== ===========================================
|
||||||
|
|
||||||
|
.. _url-building:
|
||||||
|
|
||||||
URL Building
|
URL Building
|
||||||
````````````
|
````````````
|
||||||
|
|
||||||
|
|
@ -167,7 +169,8 @@ If it can match URLs, can it also generate them? Of course you can. To
|
||||||
build a URL to a specific function you can use the :func:`~flask.url_for`
|
build a URL to a specific function you can use the :func:`~flask.url_for`
|
||||||
function. It accepts the name of the function as first argument and a
|
function. It accepts the name of the function as first argument and a
|
||||||
number of keyword arguments, each corresponding to the variable part of
|
number of keyword arguments, each corresponding to the variable part of
|
||||||
the URL rule. Here some examples:
|
the URL rule. Unknown variable parts are appended to the URL as query
|
||||||
|
parameter. Here some examples:
|
||||||
|
|
||||||
>>> from flask import Flask, url_for
|
>>> from flask import Flask, url_for
|
||||||
>>> app = Flask(__name__)
|
>>> app = Flask(__name__)
|
||||||
|
|
@ -184,9 +187,11 @@ the URL rule. Here some examples:
|
||||||
... print url_for('index')
|
... print url_for('index')
|
||||||
... print url_for('login')
|
... print url_for('login')
|
||||||
... print url_for('profile', username='John Doe')
|
... print url_for('profile', username='John Doe')
|
||||||
|
... print url_for('login', next='/')
|
||||||
...
|
...
|
||||||
/
|
/
|
||||||
/login
|
/login
|
||||||
|
/login?next=/
|
||||||
/user/John%20Doe
|
/user/John%20Doe
|
||||||
|
|
||||||
(This also uses the :meth:`~flask.Flask.test_request_context` method
|
(This also uses the :meth:`~flask.Flask.test_request_context` method
|
||||||
|
|
|
||||||
4
flask.py
4
flask.py
|
|
@ -145,6 +145,10 @@ class _RequestContext(object):
|
||||||
|
|
||||||
def url_for(endpoint, **values):
|
def url_for(endpoint, **values):
|
||||||
"""Generates a URL to the given endpoint with the method provided.
|
"""Generates a URL to the given endpoint with the method provided.
|
||||||
|
Variable arguments that are unknown to the target endpoint are appended
|
||||||
|
to the generated URL as query arguments.
|
||||||
|
|
||||||
|
For more information, head over to the :ref:`Quickstart <url-building>`.
|
||||||
|
|
||||||
:param endpoint: the endpoint of the URL (name of the function)
|
:param endpoint: the endpoint of the URL (name of the function)
|
||||||
:param values: the variable arguments of the URL rule
|
:param values: the variable arguments of the URL rule
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue