view news/models.py @ 163:7fc4123fef70

Stop passing callable to queryset. This is now deprecated. The usage here was most likely a mistake that has worked all these years. This change was for upgrading to Django 1.7.
author Brian Neal <bgneal@gmail.com>
date Thu, 02 Apr 2015 19:17:47 -0500
parents e2868ad47a1e
children
line wrap: on
line source
"""
Models for the news application.

"""
from django.db import models


class News(models.Model):
    """
    This model represents all the info we store about each news entry.

    """
    title = models.CharField(max_length=128, blank=True)
    date = models.DateTimeField(db_index=True)
    content = models.TextField()

    def __unicode__(self):
        date_str = self.date.strftime('%m/%d/%Y')
        if self.title:
            return u'%s %s' % (date_str, self.title)
        return u'%s' % date_str

    @models.permalink
    def get_absolute_url(self):
        return ('news-item', [], {'pk': str(self.id)})

    class Meta:
        verbose_name_plural = 'News'
        ordering = ['-date']