Django

Code

Changeset 4228

Show
Ignore:
Timestamp:
12/18/06 21:38:38 (2 years ago)
Author:
russellm
Message:

Fixed #3164 -- Added explicit ordering to basic model test, and revised results to suit the explicit order. Thanks to Matt Boersma for the report.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/tests/modeltests/basic/models.py

    r3826 r4228  
    1111    pub_date = models.DateTimeField() 
    1212 
     13    class Meta: 
     14        ordering = ('pub_date','headline') 
     15         
    1316    def __str__(self): 
    1417        return self.headline 
     
    246249# Slices (without step) are lazy: 
    247250>>> Article.objects.all()[0:5].filter() 
    248 [<Article: Area woman programs in Python>, <Article: Second article>, <Article: Third article>, <Article: Fourth article>, <Article: Article 6>] 
     251[<Article: Area woman programs in Python>, <Article: Second article>, <Article: Third article>, <Article: Article 6>, <Article: Default headline>] 
    249252 
    250253# Slicing again works: 
     
    254257[<Article: Area woman programs in Python>, <Article: Second article>] 
    255258>>> Article.objects.all()[0:5][4:] 
    256 [<Article: Article 6>] 
     259[<Article: Default headline>] 
    257260>>> Article.objects.all()[0:5][5:] 
    258261[] 
     
    260263# Some more tests! 
    261264>>> Article.objects.all()[2:][0:2] 
    262 [<Article: Third article>, <Article: Fourth article>] 
     265[<Article: Third article>, <Article: Article 6>] 
    263266>>> Article.objects.all()[2:][:2] 
    264 [<Article: Third article>, <Article: Fourth article>] 
     267[<Article: Third article>, <Article: Article 6>] 
    265268>>> Article.objects.all()[2:][2:3] 
    266 [<Article: Article 6>] 
     269[<Article: Default headline>] 
    267270 
    268271# Note that you can't use 'offset' without 'limit' (on some dbs), so this doesn't work: 
     
    313316# Bulk delete test: How many objects before and after the delete? 
    314317>>> Article.objects.all() 
    315 [<Article: Area woman programs in Python>, <Article: Second article>, <Article: Third article>, <Article: Fourth article>, <Article: Article 6>, <Article: Default headline>, <Article: Article 7>, <Article: Updated article 8>] 
     318[<Article: Area woman programs in Python>, <Article: Second article>, <Article: Third article>, <Article: Article 6>, <Article: Default headline>, <Article: Fourth article>, <Article: Article 7>, <Article: Updated article 8>] 
    316319>>> Article.objects.filter(id__lte=4).delete() 
    317320>>> Article.objects.all()