annotate articles/models.py @ 201:b3919dd302c9

Updated bio.
author Brian Neal <bgneal@gmail.com>
date Mon, 06 May 2019 20:29:03 -0500
parents e2868ad47a1e
children
rev   line source
bgneal@47 1 """
bgneal@47 2 Models for the articles application.
bgneal@47 3
bgneal@47 4 """
bgneal@47 5 from django.db import models
bgneal@47 6
bgneal@47 7
bgneal@47 8 class Article(models.Model):
bgneal@47 9 title = models.CharField(max_length=64)
bgneal@47 10 date = models.DateTimeField(db_index=True)
bgneal@47 11 text = models.TextField()
bgneal@47 12 source = models.TextField(help_text="Enter the source/author for the "
bgneal@47 13 "article, copyright info, etc; it will appear under the article.")
bgneal@64 14 url = models.URLField(blank=True,
bgneal@47 15 help_text = 'Link to original article; optional')
bgneal@47 16 pdf = models.FileField(upload_to = 'pdf/articles/%Y/%m/%d/', blank=True,
bgneal@47 17 help_text="If you want to make the original article available as "
bgneal@47 18 "a PDF download, you may upload it here.")
bgneal@47 19
bgneal@47 20 def __unicode__(self):
bgneal@47 21 return self.title
bgneal@47 22
bgneal@47 23 class Meta:
bgneal@47 24 ordering = ['-date']
bgneal@47 25
bgneal@47 26 @models.permalink
bgneal@47 27 def get_absolute_url(self):
bgneal@47 28 return ('articles-item', [], {'pk': str(self.id)})