Changeset 8814
- Timestamp:
- 09/01/08 16:04:01 (3 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/db/models/fields/related.py
r8782 r8814 143 143 sql, params = value.as_sql() 144 144 return QueryWrapper(('(%s)' % sql), params) 145 if lookup_type == 'exact': 145 146 # FIXME: lt and gt are explicitally allowed to make 147 # get_(next/prev)_by_date work; other lookups are not allowed since that 148 # gets messy pretty quick. This is a good candidate for some refactoring 149 # in the future. 150 if lookup_type in ['exact', 'gt', 'lt']: 146 151 return [pk_trace(value)] 147 152 if lookup_type in ('range', 'in'): django/trunk/tests/regressiontests/model_inheritance_regress/models.py
r8128 r8814 59 59 class SelfRefChild(SelfRefParent): 60 60 child_data = models.IntegerField() 61 62 class Article(models.Model): 63 headline = models.CharField(max_length=100) 64 pub_date = models.DateTimeField() 65 class Meta: 66 ordering = ('-pub_date', 'headline') 67 68 def __unicode__(self): 69 return self.headline 70 71 class ArticleWithAuthor(Article): 72 author = models.CharField(max_length=100) 61 73 62 74 __test__ = {'API_TESTS':""" … … 195 207 >>> obj.delete() 196 208 209 # Regression tests for #8076 - get_(next/previous)_by_date should 210 >>> c1 = ArticleWithAuthor(headline='ArticleWithAuthor 1', author="Person 1", pub_date=datetime.datetime(2005, 8, 1, 3, 0)) 211 >>> c1.save() 212 >>> c2 = ArticleWithAuthor(headline='ArticleWithAuthor 2', author="Person 2", pub_date=datetime.datetime(2005, 8, 1, 10, 0)) 213 >>> c2.save() 214 >>> c3 = ArticleWithAuthor(headline='ArticleWithAuthor 3', author="Person 3", pub_date=datetime.datetime(2005, 8, 2)) 215 >>> c3.save() 216 217 >>> c1.get_next_by_pub_date() 218 <ArticleWithAuthor: ArticleWithAuthor 2> 219 >>> c2.get_next_by_pub_date() 220 <ArticleWithAuthor: ArticleWithAuthor 3> 221 >>> c3.get_next_by_pub_date() 222 Traceback (most recent call last): 223 ... 224 DoesNotExist: ArticleWithAuthor matching query does not exist. 225 >>> c3.get_previous_by_pub_date() 226 <ArticleWithAuthor: ArticleWithAuthor 2> 227 >>> c2.get_previous_by_pub_date() 228 <ArticleWithAuthor: ArticleWithAuthor 1> 229 >>> c1.get_previous_by_pub_date() 230 Traceback (most recent call last): 231 ... 232 DoesNotExist: ArticleWithAuthor matching query does not exist. 233 197 234 """}
