2011-11-20 10:17:12 +00:00
|
|
|
from django.utils import timezone
|
2009-10-29 14:32:01 +00:00
|
|
|
|
2011-10-13 18:51:33 +00:00
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
|
2009-10-29 14:32:01 +00:00
|
|
|
def expensive_calculation():
|
|
|
|
expensive_calculation.num_runs += 1
|
2011-11-20 10:17:12 +00:00
|
|
|
return timezone.now()
|
2009-10-29 14:32:01 +00:00
|
|
|
|
2013-11-03 04:36:09 +00:00
|
|
|
|
2009-10-29 14:32:01 +00: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)
|