2006-05-02 09:31:56 +08:00
|
|
|
from django.db import models
|
|
|
|
|
2011-10-14 02:04:12 +08:00
|
|
|
|
2006-05-02 09:31:56 +08:00
|
|
|
class Article(models.Model):
|
2007-08-05 13:14:46 +08:00
|
|
|
headline = models.CharField(max_length=100)
|
2006-05-02 09:31:56 +08:00
|
|
|
pub_date = models.DateField()
|
|
|
|
expire_date = models.DateField()
|
2013-01-20 14:53:45 +08:00
|
|
|
|
2006-05-02 09:31:56 +08:00
|
|
|
class Meta:
|
|
|
|
get_latest_by = "pub_date"
|
|
|
|
|
2013-01-12 16:37:19 +08:00
|
|
|
|
2006-05-02 09:31:56 +08:00
|
|
|
class Person(models.Model):
|
2007-08-05 13:14:46 +08:00
|
|
|
name = models.CharField(max_length=30)
|
2006-05-02 09:31:56 +08:00
|
|
|
birthday = models.DateField()
|
|
|
|
# Note that this model doesn't have "get_latest_by" set.
|
2014-10-08 23:27:17 +08:00
|
|
|
|
|
|
|
|
|
|
|
# Ticket #23555 - model with an intentionally broken QuerySet.__iter__ method.
|
|
|
|
|
2022-02-04 03:24:19 +08:00
|
|
|
|
2014-10-08 23:27:17 +08:00
|
|
|
class IndexErrorQuerySet(models.QuerySet):
|
|
|
|
"""
|
|
|
|
Emulates the case when some internal code raises an unexpected
|
|
|
|
IndexError.
|
|
|
|
"""
|
2022-02-04 03:24:19 +08:00
|
|
|
|
2014-10-08 23:27:17 +08:00
|
|
|
def __iter__(self):
|
|
|
|
raise IndexError
|
|
|
|
|
|
|
|
|
|
|
|
class IndexErrorArticle(Article):
|
|
|
|
objects = IndexErrorQuerySet.as_manager()
|