djangosnippets.org: Latest snippets tagged with 'slugify'https://djangosnippets.org/tags/slugify/2018-02-17T03:36:28.930102-06:00Django Generate Unique Slug
2018-02-17T03:36:28.930102-06:00agusmakmunhttps://djangosnippets.org/snippets/10643/<p>Generate unique slug refference by another field.</p>
Freely redistributableBetter slugify
2011-10-30T06:03:39.736479-05:00mmajcherhttps://djangosnippets.org/snippets/2585/<p>Better slugify function for national characters. Source of original script: http://trac.django-fr.org/browser/site/trunk/project/links/slughifi.py?rev=47</p>
Freely redistributableAutomatic slug generation signal
2011-06-25T05:44:00.826148-05:00danuxhttps://djangosnippets.org/snippets/2471/<p>A pre_save signal that will automatically generate a slug for your model based on the "title" attribute, and will store the new slug in the "slug" attribute.</p>
<p>USAGE:
from django.db.models.signals import pre_save</p>
<p>from YOURPACKAGE import slug_generator</p>
<p>pre_save.connect(slug_generator, sender=YOURMODEL)</p>
Freely redistributableslugify with transliteration
2010-11-26T05:05:13.164923-06:00jezdezhttps://djangosnippets.org/snippets/2274/<p>This slugify correctly transliterates special characters using the translitcodec package from PyPI.
</p>
<p>Make sure you've installed http://pypi.python.org/pypi/translitcodec/ before using this.
</p>
Freely redistributableslug_and_slash_to_dash - modified slugify for urls
2010-08-28T13:45:26.193133-05:00bradmontgomeryhttps://djangosnippets.org/snippets/2177/<p>This filter converts slashes to spaces in a a sting and then slugify's the result. However, it ignores leading and trailing slashes. For example, it can take something like this:
</p>
<pre><code>/some/url/with-an-existing-slug/
</code></pre><p>And turn it into this:
</p>
<pre><code>some-url-with-an-existing-slug
</code></pre><p>The filter was originally written to use the <em>curent</em> url as the <code>disqus_identifier …</code></p>
Freely redistributablejQuery slugify plugin
2009-05-05T11:42:25.072907-05:00girasquidhttps://djangosnippets.org/snippets/1488/<p>This plugin lets you make a field(ideally for a slug) populate itself based on the value of another field. You use it like this:</p>
<p>jQuery('#id_title').slugify('#id_slug');</p>
Freely redistributableBuilt-in Slugify with filtering.
2009-04-10T11:52:14.034377-05:00jcrawfordhttps://djangosnippets.org/snippets/1427/<p>This is based on snippets 29 and 43, both of which had good ideas, and I thought, "why not combine them?"</p>
<p>Given the new_topic string above, the resulting slug will be:</p>
<p>"test-long-string-which-has-many-words-here"</p>
<p>John Crawford</p>
<p>Note - requires python 2.5, for list comprehensions. Otherwise you could just use a for loop …</p>
Freely redistributableunique_slugify
2009-02-12T18:27:57.539584-06:00crucialfelixhttps://djangosnippets.org/snippets/1321/<p>sorry, this is a duplicate post, original is here:</p>
<p>http://www.djangosnippets.org/snippets/690/</p>
<p>no way to delete snippets</p>
Freely redistributableautotranslatslugify
2007-04-15T15:14:34.213925-05:00Ciantichttps://djangosnippets.org/snippets/180/<p>Changes <strong>all slugify calls</strong> to support translat automatically, behind the scenes. Using this one doesn't have to change any models or code to make it work everywhere.</p>
<p>Create new project, I call it myself <em>autoslugifytranslat</em>, and add the following to project's <code>__init__.py</code> file. It will automatically add translat slugify …</p>
Freely redistributableSlugify alternative
2007-04-10T14:09:39.084873-05:00exogenhttps://djangosnippets.org/snippets/168/<p>I prefer to use this slugification function rather than the one included with Django. It uses underscores instead of dashes for spaces, and allows dashes and periods to occur normally in the string. I decided on this when considering reasonable slugified titles such as...</p>
<pre><code>object-relational_mapper_2.5
ten_reasons_web-2.0_rocks
django-trunk_0.99_updated
</code></pre>
Freely redistributable