bgneal@47: """ bgneal@47: Models for the articles application. bgneal@47: bgneal@47: """ bgneal@47: from django.db import models bgneal@47: bgneal@47: bgneal@47: class Article(models.Model): bgneal@47: title = models.CharField(max_length=64) bgneal@47: date = models.DateTimeField(db_index=True) bgneal@47: text = models.TextField() bgneal@47: source = models.TextField(help_text="Enter the source/author for the " bgneal@47: "article, copyright info, etc; it will appear under the article.") bgneal@64: url = models.URLField(blank=True, bgneal@47: help_text = 'Link to original article; optional') bgneal@47: pdf = models.FileField(upload_to = 'pdf/articles/%Y/%m/%d/', blank=True, bgneal@47: help_text="If you want to make the original article available as " bgneal@47: "a PDF download, you may upload it here.") bgneal@47: bgneal@47: def __unicode__(self): bgneal@47: return self.title bgneal@47: bgneal@47: class Meta: bgneal@47: ordering = ['-date'] bgneal@47: bgneal@47: @models.permalink bgneal@47: def get_absolute_url(self): bgneal@47: return ('articles-item', [], {'pk': str(self.id)})