evorepo/news/models.py
Dan McGee 7c92ddbd3c Add migrations to populate the news slug and make it non-null
These should get us all set to have more useful URLs for the news items.

Signed-off-by: Dan McGee <dan@archlinux.org>
2010-09-21 09:10:02 -05:00

27 lines
824 B
Python

from django.db import models
from django.contrib.auth.models import User
class News(models.Model):
id = models.AutoField(primary_key=True)
slug = models.SlugField(max_length=255, unique=True)
author = models.ForeignKey(User, related_name='news_author')
postdate = models.DateTimeField("post date", auto_now_add=True, db_index=True)
last_modified = models.DateTimeField(editable=False,
auto_now=True, db_index=True)
title = models.CharField(max_length=255)
content = models.TextField()
def get_absolute_url(self):
return '/news/%i/' % self.id
def __unicode__(self):
return self.title
class Meta:
db_table = 'news'
verbose_name_plural = 'news'
get_latest_by = 'postdate'
ordering = ['-postdate']
# vim: set ts=4 sw=4 et: