2011-11-20 18:17:12 +08:00
|
|
|
from django.utils import timezone
|
2009-10-29 22:32:01 +08:00
|
|
|
|
2011-10-14 02:51:33 +08:00
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
|
2009-10-29 22:32:01 +08:00
|
|
|
def expensive_calculation():
|
|
|
|
expensive_calculation.num_runs += 1
|
2011-11-20 18:17:12 +08:00
|
|
|
return timezone.now()
|
2009-10-29 22:32:01 +08:00
|
|
|
|
2013-11-03 12:36:09 +08:00
|
|
|
|
2009-10-29 22:32:01 +08:00
|
|
|
class Poll(models.Model):
|
|
|
|
question = models.CharField(max_length=200)
|
|
|
|
answer = models.CharField(max_length=200)
|
|
|
|
pub_date = models.DateTimeField('date published', default=expensive_calculation)
|