1a18ca4771
This will come in handy when determining whether resources are out of date, such as our news RSS feed. Also bump the Date fields to DateTime fields for sake of sorting and if we have more than one news item on the same date. Signed-off-by: Dan McGee <dan@archlinux.org>
26 lines
761 B
Python
26 lines
761 B
Python
from django.db import models
|
|
from django.contrib.auth.models import User
|
|
|
|
class News(models.Model):
|
|
id = models.AutoField(primary_key=True)
|
|
author = models.ForeignKey(User, related_name='news_author')
|
|
postdate = models.DateTimeField(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', '-id']
|
|
|
|
# vim: set ts=4 sw=4 et:
|