source: src/django_tutorial/polls/models.py@ 9178

Last change on this file since 9178 was 9009, checked in by dennisw, 14 years ago

Stuk tutorial erbij, prototype model gemaakt.

File size: 543 bytes
RevLine 
[9009]1from django.db import models
2import datetime
3
4class Poll(models.Model):
5 question = models.CharField(max_length=200)
6 pub_date = models.DateTimeField('date published')
7 def __unicode__(self):
8 return self.question
9 def was_published_today(self):
10 return self.pub_date.date() == datetime.date.today()
11 was_published_today.short_description = 'Published today?'
12
13class Choice(models.Model):
14 poll = models.ForeignKey(Poll)
15 choice = models.CharField(max_length=200)
16 votes = models.IntegerField()
17 def __unicode__(self):
18 return self.choice
19
Note: See TracBrowser for help on using the repository browser.