comparison countdown/models.py @ 1081:ecb8f07d937b

Added countdown application.
author Brian Neal <bgneal@gmail.com>
date Sun, 24 Apr 2016 12:27:26 -0500
parents
children
comparison
equal deleted inserted replaced
1080:db8f5b3204b7 1081:ecb8f07d937b
1 from django.db import models
2
3
4 class ActiveEventManager(models.Manager):
5 """Manager for all active events."""
6 def get_queryset(self):
7 return super(ActiveEventManager, self).get_queryset().filter(
8 is_active=True)
9
10
11 class Event(models.Model):
12 """Model for events we are counting down for."""
13 name = models.CharField(max_length=64)
14 url = models.URLField(max_length=200)
15 event_date = models.DateTimeField()
16 is_active = models.BooleanField(db_index=True)
17
18 objects = models.Manager()
19 active_objects = ActiveEventManager()
20
21 def __unicode__(self):
22 return u"{} on {}".format(
23 self.name, self.event_date.strftime('%m/%d/%Y'))
24
25 class Meta:
26 ordering = ['event_date']