# HG changeset patch # User Brian Neal # Date 1260740828 0 # Node ID dac690ab98b2eb2ac2d8abd79ca691f700512e7b # Parent 3e22a6fde2d2b7e6ba836540634aee6d974bc3ac Display video sets on index page by date in descending order. Allow the video set date to be edited. diff -r 3e22a6fde2d2 -r dac690ab98b2 mysite/band/models.py --- a/mysite/band/models.py Tue Jun 02 00:47:37 2009 +0000 +++ b/mysite/band/models.py Sun Dec 13 21:47:08 2009 +0000 @@ -221,7 +221,7 @@ ####################################################################### class Video_Set(models.Model): - date = models.DateField(auto_now_add = True, editable = False) + date = models.DateField(blank=True) title = models.CharField(max_length = 64) text = models.TextField() @@ -232,6 +232,12 @@ ordering = ('date', ) verbose_name = "Video Set" + def save(self, *args, **kwargs): + if not self.id: + self.date = datetime.date.today() + + super(Video_Set, self).save(*args, **kwargs) + ####################################################################### class Video(models.Model): diff -r 3e22a6fde2d2 -r dac690ab98b2 mysite/band/views.py --- a/mysite/band/views.py Tue Jun 02 00:47:37 2009 +0000 +++ b/mysite/band/views.py Sun Dec 13 21:47:08 2009 +0000 @@ -173,7 +173,7 @@ ####################################################################### def videos_index(request): - vidsets = Video_Set.objects.values('title', 'id').order_by('-id') + vidsets = Video_Set.objects.values('title', 'id').order_by('-date') return render_to_response('band/videos.html', { 'vidsets' : vidsets }, context_instance = RequestContext(request))