diff options
Diffstat (limited to 'apps/docs/models.py')
-rw-r--r-- | apps/docs/models.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/apps/docs/models.py b/apps/docs/models.py new file mode 100644 index 0000000..bd95207 --- /dev/null +++ b/apps/docs/models.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- + +from django.db import models +from django.template.defaultfilters import slugify + + +class Image(models.Model): + image = models.ImageField(upload_to='media/images') + title = models.CharField(max_length=128, null=True) + + +class Article(models.Model): + slug = models.SlugField(editable=False) + title = models.CharField(max_length=255) + content = models.TextField() + published = models.BooleanField(default=True) + created_at = models.DateTimeField(auto_now=True) + updated_at = models.DateTimeField(auto_now=True) + + images = models.ManyToManyField(Image, null=True) + + def __unicode__(self): + return self.title + + def save(self, *args, **kwargs): + self.slug = slugify(self.title) + super(Article, self).save(*args, **kwargs) |