4

In Django generic views, there's slug_field, and slug_url_kwarg. In this context, what is the definition of slug?

I choose the more persuasive explanation within items of 3 dictionaries.

In Cambridge dictionary:

A piece of metal used instead of a coin for putting in machines

In MW:

A disk for insertion in a slot machine; especially :one used illegally instead of a coin

In Oxford:

A part of a URL which identifies a particular page on a website in a form readable by users.

They don't seem to make sense.

  • 3
    The last one does make sense – tkausl Oct 29 '17 at 05:34
  • Clearly the Oxford definition is the correct one here. Are you making a joke? Or is there information you're leaving out, which contradicts the Oxford definition in this context? – Max von Hippel Oct 29 '17 at 05:37
  • puzzled about what's the oxford's definition originated from? from insertion? –  Oct 29 '17 at 05:41

1 Answers1

2

It is from the publishing world from wikipedia:

In newspaper editing, a slug is a short name given to an article that is in production. The story is labeled with its slug as it makes its way from the reporter through the editorial process. The AP Stylebook prescribes its use by wire reporters (in a "keyword slugline") as follows: "The keyword or slug (sometimes more than one word) clearly indicates the content of the story."[1] Sometimes a slug also contains code information that tells editors specific information about the story — for example, the letters "AM" at the beginning of a slug on a wire story tell editors that the story is meant for morning papers, while the letters "CX" indicate that the story is a correction to an earlier story.[2][3] In the production process of print advertisements, a slug or slug line, refers to the "name" of a particular advertisement. Advertisements usually have several markers, ad numbers or job numbers and slug lines. Usually the slug references the offer or headline and is used to differentiate between different ad runs.

From there, the slug for web publishing was born as an effort to make more semantic URLs. This is the slug as used in django:

Some systems define a slug as the part of a URL that identifies a page in human-readable keywords.[4][5] It is usually the end part of the URL, which can be interpreted as the name of the resource, similar to the basename in a filename or the title of a page. The name is based on the use of the word slug in the news media to indicate a short name given to an article for internal use. Slugs are typically generated automatically from a page title but can also be entered or altered manually, so that while the page title remains designed for display and human readability, its slug may be optimized for brevity or for consumption by search engines. Long page titles may also be truncated to keep the final URL to a reasonable length. Slugs are generally entirely lowercase, with accented characters replaced by letters from the English alphabet and whitespace characters replaced by a dash or an underscore to avoid being encoded. Punctuation marks are generally removed, and some also remove short, common words such as conjunctions. For example:

Original title: This, That and the Other! An Outré Collection

Generated slug: this-that-other-outre-collection

Django provides a slug field, and in its documentation provides a definition as well:

Slug is a newspaper term. A slug is a short label for something, containing only letters, numbers, underscores or hyphens. They’re generally used in URLs.

Community
  • 1
  • 1
Burhan Khalid
  • 169,990
  • 18
  • 245
  • 284
  • 1
    Got it. extends its original meanning 'An amount of alcoholic drink that is gulped or poured.' In publishing and in web, can be understood as ' get a refined part from the whole' –  Oct 29 '17 at 05:59