Opened 21 months ago

Closed 21 months ago

Last modified 21 months ago

#21723 closed Cleanup/optimization (worksforme)

relative vs absolute in url tag documentation

Reported by: cjerdonek Owned by: nobody
Component: Documentation Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no


The language describing the url template tag is somewhat confusing because it uses the word "absolute" to describe a relative URL:

url: Returns an absolute path reference (a URL without the domain name) matching a given view...

I would replace this with language something like:

url: Returns the relative URL (URL without domain name) for the given view...

The key suggestion here is to use "relative" instead of "absolute."

Change History (2)

comment:1 Changed 21 months ago by mjtamlyn

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to worksforme
  • Status changed from new to closed

Django uses the language "absolute url" to refer to the URL without the domain name in a few places. In particular the get_absolute_url() function.

To me, relative url implies a url like ../../foo/bar, not a url like /foo/bar. Strictly speaking, the url /foo/bar is neither relative or absolute, but it's closer to absolute.

comment:2 Changed 21 months ago by cjerdonek

I read the latest RFC (RFC 3986) on this topic. According to that document, the return value is an "absolute-path URI reference," which is a kind of relative URI reference. In contrast, an absolute URI includes the scheme.

Django also has HttpRequest.build_absolute_uri(), which returns an absolute URI.

I still think the wording can be improved. "Absolute path reference" seems obscure to me, and "URL" is mentioned only parenthetically in the first sentence about "url." When I first read that sentence, I thought it was trying to say "absolute URL reference," which lead to the confusion. An early version of the docs even says exactly that, "Returns an absolute URL (i.e., a URL without the domain name)" (from v1.1 docs).

Note: See TracTickets for help on using tickets.
Back to Top