Commit 268bc3b1 by Alex Gaynor

Added slug to Tag.

parent 83b520da
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes.generic import GenericForeignKey from django.contrib.contenttypes.generic import GenericForeignKey
from django.db import models from django.db import models
from django.template.defaultfilters import slugify
class Tag(models.Model): class Tag(models.Model):
name = models.CharField(max_length=100) name = models.CharField(max_length=100)
slug = models.SlugField()
def __unicode__(self): def __unicode__(self):
return self.name return self.name
def save(self, *args, **kwargs):
if not self.pk:
self.slug = slugify(self.name)
super(Tag, self).save(*args, **kwargs)
class TaggedItem(models.Model): class TaggedItem(models.Model):
object_id = models.IntegerField() object_id = models.IntegerField()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment