comparison gpp/potd/models.py @ 14:7b6540b185d9

Added get_absolute_url() for my comments. Had to add a get_absolute_url() function for downloads in the process.
author Brian Neal <bgneal@gmail.com>
date Sat, 18 Apr 2009 19:14:17 +0000
parents dbd703f7d63a
children 5c889b587416
comparison
equal deleted inserted replaced
13:777451a98f9d 14:7b6540b185d9
32 description = models.TextField() 32 description = models.TextField()
33 user = models.ForeignKey(User) 33 user = models.ForeignKey(User)
34 date_added = models.DateField(auto_now_add=True) 34 date_added = models.DateField(auto_now_add=True)
35 potd_count = models.IntegerField(default=0) 35 potd_count = models.IntegerField(default=0)
36 36
37 class Meta:
38 ordering = ('-date_added', '-caption')
39
37 def __unicode__(self): 40 def __unicode__(self):
38 return u'%s (%s)' % (self.caption, self.pk) 41 return u'%s (%s)' % (self.caption, self.pk)
39 42
40 class Meta: 43 @models.permalink
41 ordering = ('-date_added', '-caption') 44 def get_absolute_url(self):
45 return ('potd-archive', [str(self.id)])
42 46
43 def save(self, force_insert=False, force_update=False): 47 def save(self, force_insert=False, force_update=False):
44 48
45 if self.thumb: 49 if self.thumb:
46 self.thumb.delete(save=False) 50 self.thumb.delete(save=False)