(
    context: _Context,
    __route_name: str,
    query_: Optional[Dict[str, str]] = None,
    **parts: Union[str, int]
)
return url
Filter for generating urls.

    Usage: {{ url('the-view-name') }} might become "/path/to/view" or
    {{ url('item-details', id=123, query_={'active': 'true'}) }}
    might become "/items/1?active=true".
Filter for generating urls.
Filter for generating urls .
def url_for(
    context: _Context,
    __route_name: str,
    query_: Optional[Dict[str, str]] = None,
    **parts: Union[str, int]
) -> URL:
    """Filter for generating urls.

    Usage: {{ url('the-view-name') }} might become "/path/to/view" or
    {{ url('item-details', id=123, query_={'active': 'true'}) }}
    might become "/items/1?active=true".
    """
    app = context["app"]

    parts_clean: Dict[str, str] = {}
    for key in parts:
        val = parts[key]
        if isinstance(val, str):
            # if type is inherited from str expilict cast to str makes sense
            # if type is exactly str the operation is very fast
            val = str(val)
        elif type(val) is int:
            # int inherited classes like bool are forbidden
            val = str(val)
        else:
            raise TypeError(
                "argument value should be str or int, "
                "got {} -> [{}] {!r}".format(key, type(val), val)
            )
        parts_clean[key] = val

    url = app.router[__route_name].url_for(**parts_clean)
    if query_:
        url = url.with_query(query_)
    return url
def url_for ( context : _Context , __route_name : str , query_ : Optional [ Dict [ str , str ] ] = None , * * parts : Union [ str , int ] ) -> URL : app = context [ "app" ] parts_clean : Dict [ str , str ] = { } for key in parts : val = parts [ key ] if isinstance ( val , str ) : # if type is inherited from str expilict cast to str makes sense # if type is exactly str the operation is very fast val = str ( val ) elif type ( val ) is int : # int inherited classes like bool are forbidden val = str ( val ) else : raise TypeError ( "argument value should be str or int, " "got {} -> [{}] {!r}" . format ( key , type ( val ) , val ) ) parts_clean [ key ] = val url = app . router [ __route_name ] . url_for ( * * parts_clean ) if query_ : url = url . with_query ( query_ ) return url