All pastes #17995 Raw Edit

polls.py

public text v1 · immutable
#17995 ·published 2005-07-18 18:25 UTC
rendered paste body
from django.core import meta

# Create your models here.

class Poll(meta.Model):

    def __repr__(self):
        return self.question
        
    def was_published_today(self):
        return self.pub_date.date()==datetime.date.today()
        
    fields = (
        meta.CharField('question', 'question',  maxlength=200),
        meta.DateTimeField('pub_date', 'date published'),
    )
    
class Choice(meta.Model):

    def __repr__(self):
        return self.question
        
    fields = (
        meta.ForeignKey(Poll),
        meta.CharField('choice', 'choice', maxlength=200),
        meta.IntegerField('votes', 'votes'),
    )