gpt4 book ai didi

django - Django 中的 'slug' 是什么?

转载 作者:行者123 更新时间:2023-12-04 03:08:35 24 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





What is a "slug" in Django?

(12 个回答)


4年前关闭。




在 Django 通用 View 中,有 slug_field , 和 slug_url_kwarg .
在这种情况下,slug 的定义是什么?

我在3本词典的项目中选择了更有说服力的解释。

在剑桥词典中:

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



兆瓦:

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



在牛津:

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



它们似乎没有意义。

最佳答案

它来自出版界 wikipedia :

In newspaper editing, a slug is a short name given to an article thatis in production. The story is labeled with its slug as it makes itsway from the reporter through the editorial process. The AP Stylebookprescribes its use by wire reporters (in a "keyword slugline") asfollows: "The keyword or slug (sometimes more than one word) clearlyindicates the content of the story."[1] Sometimes a slug also containscode information that tells editors specific information about thestory — for example, the letters "AM" at the beginning of a slug on awire story tell editors that the story is meant for morning papers,while the letters "CX" indicate that the story is a correction to anearlier story.[2][3] In the production process of printadvertisements, a slug or slug line, refers to the "name" of aparticular advertisement. Advertisements usually have several markers,ad numbers or job numbers and slug lines. Usually the slug referencesthe offer or headline and is used to differentiate between differentad runs.


从那里开始, web publishing 的弹头诞生是为了制作更多语义 URL。这是 django 中使用的 slug:

Some systems define a slug as the part of a URL that identifies a pagein human-readable keywords.[4][5] It is usually the end part of theURL, which can be interpreted as the name of the resource, similar tothe basename in a filename or the title of a page. The name is basedon the use of the word slug in the news media to indicate a short namegiven to an article for internal use. Slugs are typically generatedautomatically from a page title but can also be entered or alteredmanually, so that while the page title remains designed for displayand human readability, its slug may be optimized for brevity or forconsumption by search engines. Long page titles may also be truncatedto keep the final URL to a reasonable length. Slugs are generallyentirely lowercase, with accented characters replaced by letters fromthe English alphabet and whitespace characters replaced by a dash oran underscore to avoid being encoded. Punctuation marks are generallyremoved, and some also remove short, common words such asconjunctions. For example:

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

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


Django 提供了一个 slug 字段,以及 in its documentation还提供了一个定义:

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

关于django - Django 中的 'slug' 是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46997142/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com