Skip to main content

url_for

Generate a URL to the given endpoint with the given values. This requires an active request or application context, and calls :meth:current_app.url_for() < flask.Flask.url_for >. See that method for full documentation.

def url_for(
endpoint: str,
_anchor: str | None = None,
_method: str | None = None,
_scheme: str | None = None,
_external: bool | None = None,
**values: Any
) - > string

Generate a URL to the given endpoint with the given values. This requires an active request or application context, and calls :meth:current_app.url_for() < flask.Flask.url_for >. See that method for full documentation.

Parameters

NameTypeDescription
endpointstrThe endpoint name associated with the URL to generate. If this starts with a ".", the current blueprint name (if any) will be used.
_anchor`strNone` = None
_method`strNone` = None
_scheme`strNone` = None
_external`boolNone` = None
**valuesAnyValues to use for the variable parts of the URL rule. Unknown keys are appended as query string arguments, like "?a=b&c=d".

Returns

TypeDescription
stringThe generated URL string, including the scheme and domain if external, and any query parameters or anchors.