django-smart-slug 0.1.0

A smart slug field for your models

  Add it to your Download Basket!

 Add it to your Watch List!

0/5

Rate it!
send us
an update
LICENSE TYPE:
MIT/X Consortium License 
USER RATING:
UNRATED
  0.0/5
DEVELOPED BY:
Charles Leifer
HOMEPAGE:
github.com
CATEGORY:
ROOT \ Internet \ HTTP (WWW)
django-smart-slug is a Django app that provides slug fields for the lazy.

Examples

There are exhausting examples in the tests, but here's the quick rundown:

from django.db import models
from smart_slug.fields import SmartSlugField

class Simple(models.Model):
 slug = SmartSlugField(max_length=5, underscores=False)

class Complex(models.Model):
 title = models.CharField(max_length=100)
 slug = SmartSlugField(
 source_field='title',
 date_field='pub_date',
 split_on_words=True,
 max_length=10)
 pub_date = models.DateTimeField(auto_now=True)

>>> s1 = Simple.objects.create(slug='simple')
>>> s1.slug
simpl

>>> s2 = Simple.objects.create(slug='simple')
>>> s2.slug
sim-1

>>> s3 = Simple.objects.create(slug='simple')
>>> s3.slug
sim-2

>>> c1 = Complex.objects.create(title='complex example')
>>> c1.slug
complex

>>> c2 = Complex.objects.create(title='complex example')
>>> c2.slug
complex_

Last updated on July 6th, 2010

requirements

#slug field #Django plugin #Django #slug #field #plugin

Add your review!

SUBMIT