tests/cache/models.py
raw| 1 | from django.db import models |
| 2 | from django.utils import timezone |
| 3 | |
| 4 | |
| 5 | def expensive_calculation(): |
| 6 | expensive_calculation.num_runs += 1 |
| 7 | return timezone.now() |
| 8 | |
| 9 | |
| 10 | class Poll(models.Model): |
| 11 | question = models.CharField(max_length=200) |
| 12 | answer = models.CharField(max_length=200) |
| 13 | pub_date = models.DateTimeField("date published", default=expensive_calculation) |