Browse Source

Docs mention query args now. This fixes #20

pull/1638/head
Armin Ronacher 15 years ago
parent
commit
f1603d33f2
  1. 7
      docs/quickstart.rst
  2. 4
      flask.py

7
docs/quickstart.rst

@ -160,6 +160,8 @@ The following converters exist:
`path` like the default but also accepts slashes
=========== ===========================================
.. _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`
function. It accepts the name of the function as first argument and a
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
>>> app = Flask(__name__)
@ -184,9 +187,11 @@ the URL rule. Here some examples:
... print url_for('index')
... print url_for('login')
... print url_for('profile', username='John Doe')
... print url_for('login', next='/')
...
/
/login
/login?next=/
/user/John%20Doe
(This also uses the :meth:`~flask.Flask.test_request_context` method

4
flask.py

@ -145,6 +145,10 @@ class _RequestContext(object):
def url_for(endpoint, **values):
"""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 values: the variable arguments of the URL rule

Loading…
Cancel
Save