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