All pastes #386331 Raw Edit

Miscellany

public python v1 · immutable
·published 2007-03-08 15:01 UTC
rendered paste body
from django.db import modelsimport datetime # Create your models here.class Poll(models.Model):    def __str__(self):         return self.question    question = models.CharField(maxlength=200)    pub_date = models.DateTimeField('date published')    def publ_today(self):        return self.pub_date.date() == datetime.date.today()    publ_today.short_description = 'Published today?'    class Admin:        fields = (            (None, {'fields': ('question')}),            ('Date information:', {'fields': ('pub_date',), 'classes': 'collapse'}),        )        list_display = ('question', 'pub_date', 'publ_today')        list_filter = ['pub_date']class Choice(models.Model):    poll = models.ForeignKey(Poll, edit_inline=models.STACKED, num_in_admin=3)    choice = models.CharField(maxlength=200, core=True)    votes = models.IntegerField(core=True)    def __str__(self):        return self.choice