Mercurial > public > sg101
comparison potd/models.py @ 1206:02181fa5ac9d modernize tip
Update to Django 1.9.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 22 Jan 2025 17:58:16 -0600 |
parents | eeaf387803c6 |
children |
comparison
equal
deleted
inserted
replaced
1205:510ef3cbf3e6 | 1206:02181fa5ac9d |
---|---|
31 """Model to represent a POTD""" | 31 """Model to represent a POTD""" |
32 photo = models.ImageField(upload_to='potd/%Y/%m/%d') | 32 photo = models.ImageField(upload_to='potd/%Y/%m/%d') |
33 thumb = models.ImageField(upload_to='potd/%Y/%m/%d/thumbs', blank=True, null=True) | 33 thumb = models.ImageField(upload_to='potd/%Y/%m/%d/thumbs', blank=True, null=True) |
34 caption = models.CharField(max_length=128) | 34 caption = models.CharField(max_length=128) |
35 description = models.TextField() | 35 description = models.TextField() |
36 user = models.ForeignKey(User, related_name='potd_set') | 36 user = models.ForeignKey(User, related_name='potd_set', |
37 on_delete=models.CASCADE) | |
37 date_added = models.DateField() | 38 date_added = models.DateField() |
38 potd_count = models.IntegerField(default=0) | 39 potd_count = models.IntegerField(default=0) |
39 | 40 |
40 class Meta: | 41 class Meta: |
41 ordering = ('-date_added', '-caption') | 42 ordering = ('-date_added', '-caption') |
113 return None | 114 return None |
114 | 115 |
115 | 116 |
116 class Current(models.Model): | 117 class Current(models.Model): |
117 """This model simply stores the current POTD.""" | 118 """This model simply stores the current POTD.""" |
118 potd = models.ForeignKey(Photo) | 119 potd = models.ForeignKey(Photo, on_delete=models.CASCADE) |
119 | 120 |
120 objects = CurrentManager() | 121 objects = CurrentManager() |
121 | 122 |
122 def __unicode__(self): | 123 def __unicode__(self): |
123 return self.potd.__unicode__() | 124 return self.potd.__unicode__() |