Skip to main content

resolve_url

Return a URL appropriate for the arguments passed.

The arguments could be:

* A model: the model's `get_absolute_url()` function will be called.

* A view name, possibly with arguments: `urls.reverse()` will be used
to reverse-resolve the name.

* A URL, which will be returned as-is.
def resolve_url(
to: Union[Model, Callable, str],
*args: tuple,
**kwargs: dict
) - > string

Return a URL appropriate for the arguments passed.

Parameters

NameTypeDescription
toUnion[Model, Callable, str]The target to resolve, which can be a model instance with get_absolute_url, a view name to be reversed, or a direct URL string.
*argstuplePositional arguments passed to the URL reverse function if a view name is provided.
**kwargsdictKeyword arguments passed to the URL reverse function if a view name is provided.

Returns

TypeDescription
stringThe resolved URL string, which could be a model's absolute URL, a reversed view path, or the original URL string.