Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Refs #15550 -- Corrected another primary-key ordering problem in the …

…modelforms tests. Thanks to bberes for the report.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15753 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 18f42f546a1bb7478829986154375abf37762e13 1 parent 90564a1
Russell Keith-Magee authored March 04, 2011

Showing 1 changed file with 12 additions and 9 deletions. Show diff stats Hide diff stats

  1. 21  tests/modeltests/model_forms/models.py
21  tests/modeltests/model_forms/models.py
@@ -169,12 +169,15 @@ class ArticleStatus(models.Model):
169 169
     status = models.CharField(max_length=2, choices=ARTICLE_STATUS_CHAR, blank=True, null=True)
170 170
 
171 171
 class Inventory(models.Model):
172  
-   barcode = models.PositiveIntegerField(unique=True)
173  
-   parent = models.ForeignKey('self', to_field='barcode', blank=True, null=True)
174  
-   name = models.CharField(blank=False, max_length=20)
  172
+    barcode = models.PositiveIntegerField(unique=True)
  173
+    parent = models.ForeignKey('self', to_field='barcode', blank=True, null=True)
  174
+    name = models.CharField(blank=False, max_length=20)
175 175
 
176  
-   def __unicode__(self):
177  
-      return self.name
  176
+    class Meta:
  177
+        ordering = ('name',)
  178
+
  179
+    def __unicode__(self):
  180
+        return self.name
178 181
 
179 182
 class Book(models.Model):
180 183
     title = models.CharField(max_length=40)
@@ -1530,8 +1533,8 @@ class FlexibleDatePost(models.Model):
1530 1533
 ...     print choice
1531 1534
 (u'', u'---------')
1532 1535
 (86, u'Apple')
1533  
-(22, u'Pear')
1534 1536
 (87, u'Core')
  1537
+(22, u'Pear')
1535 1538
 
1536 1539
 >>> class InventoryForm(ModelForm):
1537 1540
 ...     class Meta:
@@ -1541,8 +1544,8 @@ class FlexibleDatePost(models.Model):
1541 1544
 <select name="parent" id="id_parent">
1542 1545
 <option value="">---------</option>
1543 1546
 <option value="86" selected="selected">Apple</option>
1544  
-<option value="22">Pear</option>
1545 1547
 <option value="87">Core</option>
  1548
+<option value="22">Pear</option>
1546 1549
 </select>
1547 1550
 
1548 1551
 >>> data = model_to_dict(core)
@@ -1571,8 +1574,8 @@ class FlexibleDatePost(models.Model):
1571 1574
 >>> for choice in field.choices:
1572 1575
 ...     print choice
1573 1576
 (86, u'Apple')
1574  
-(22, u'Pear')
1575 1577
 (87, u'Core')
  1578
+(22, u'Pear')
1576 1579
 >>> field.clean([86])
1577 1580
 [<Inventory: Apple>]
1578 1581
 
@@ -1582,7 +1585,7 @@ class FlexibleDatePost(models.Model):
1582 1585
 >>> form.is_valid()
1583 1586
 True
1584 1587
 >>> form.cleaned_data
1585  
-{'items': [<Inventory: Pear>, <Inventory: Core>]}
  1588
+{'items': [<Inventory: Core>, <Inventory: Pear>]}
1586 1589
 
1587 1590
 # Model field that returns None to exclude itself with explicit fields ########
1588 1591
 

0 notes on commit 18f42f5

Please sign in to comment.
Something went wrong with that request. Please try again.