def fullurl(parser, token):
"""
Builds an absolute (full) URL from the given location and the variables available in the request.
If no location is specified, the absolute (full) URL is built on :py:meth:`django.http.HttpRequest.get_full_path`.
It is a wrapper around :py:meth:`django.http.HttpRequest.build_absolute_uri`. It requires ``request`` to be available
in the template context (for example, by using ``django.core.context_processors.request`` context processor).
Samply usage::
{% url path.to.some_view as the_url %}
{% fullurl the_url %}
"""
args = list(token.split_contents())
if len(args) > 2:
raise template.TemplateSyntaxError("'%s' tag requires at most one argument" % args[0])
if len(args) == 2:
url = parser.compile_filter(args[1])
else:
url = None
return FullUrlNode(url)
评论列表
文章目录