Mercurial > public > sg101
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/countdown/models.py Sun Apr 24 12:27:26 2016 -0500 @@ -0,0 +1,26 @@ +from django.db import models + + +class ActiveEventManager(models.Manager): + """Manager for all active events.""" + def get_queryset(self): + return super(ActiveEventManager, self).get_queryset().filter( + is_active=True) + + +class Event(models.Model): + """Model for events we are counting down for.""" + name = models.CharField(max_length=64) + url = models.URLField(max_length=200) + event_date = models.DateTimeField() + is_active = models.BooleanField(db_index=True) + + objects = models.Manager() + active_objects = ActiveEventManager() + + def __unicode__(self): + return u"{} on {}".format( + self.name, self.event_date.strftime('%m/%d/%Y')) + + class Meta: + ordering = ['event_date']