Skip to content

Instantly share code, notes, and snippets.

@rwmyers
Created March 1, 2012 04:46
Show Gist options
  • Select an option

  • Save rwmyers/1947346 to your computer and use it in GitHub Desktop.

Select an option

Save rwmyers/1947346 to your computer and use it in GitHub Desktop.
AutoSlugField Model
from django.db import models
from autoslug import AutoSlugField
class Post(models.Model):
title = models.CharField(max_length=120, unique=True)
slug = AutoSlugField(populate_from='title', max_length=50, unique=True)
body = models.CharField()
posted = models.DateField(auto_now=True)
def __unicode__(self):
return self.title
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment