Guest User

Untitled

a guest
Mar 27th, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. import datetime
  2. from django.db import models
  3. from django.utils import timezone
  4.  
  5. # Create your models here.
  6. class Poll(models.Model):
  7.     question = models.CharField(max_length=200)
  8.     pub_date = models.DateTimeField('date published')
  9.    
  10.     def __unicode__(self):
  11.     return self.question
  12.  
  13.     def was_published_recently(self):
  14.         return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
  15.  
  16. class Choice(models.Model):
  17.     poll = models.ForeignKey(Poll)
  18.     choice_text = models.CharField(max_length=200)
  19.     votes = models.IntegerField(default=0)
  20.    
  21.     def __unicode__(self):
  22.     return self.choice_text
Advertisement
Add Comment
Please, Sign In to add comment