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