1
0
mirror of https://github.com/django/django.git synced 2024-12-25 10:35:48 +00:00

Fixed #8067 -- Replaced dict literals in the model_formsets tests with sorted lists of tuples to ensure compatibilty on different implementations of Python. Thanks Leo Soto for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8178 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Brian Rosner 2008-08-01 20:12:18 +00:00
parent 4c0234215e
commit 61b335700c

View File

@ -1,5 +1,10 @@
from django.db import models from django.db import models
try:
sorted
except NameError:
from django.utils.itercompat import sorted
class Author(models.Model): class Author(models.Model):
name = models.CharField(max_length=100) name = models.CharField(max_length=100)
@ -212,13 +217,14 @@ used.
>>> AuthorFormSet = modelformset_factory(Author, max_num=2) >>> AuthorFormSet = modelformset_factory(Author, max_num=2)
>>> formset = AuthorFormSet(queryset=qs) >>> formset = AuthorFormSet(queryset=qs)
>>> formset.initial >>> [sorted(x.items()) for x in formset.initial]
[{'id': 1, 'name': u'Charles Baudelaire'}, {'id': 3, 'name': u'Paul Verlaine'}] [[('id', 1), ('name', u'Charles Baudelaire')], [('id', 3), ('name', u'Paul Verlaine')]]
>>> AuthorFormSet = modelformset_factory(Author, max_num=3) >>> AuthorFormSet = modelformset_factory(Author, max_num=3)
>>> formset = AuthorFormSet(queryset=qs) >>> formset = AuthorFormSet(queryset=qs)
>>> formset.initial >>> [sorted(x.items()) for x in formset.initial]
[{'id': 1, 'name': u'Charles Baudelaire'}, {'id': 3, 'name': u'Paul Verlaine'}, {'id': 2, 'name': u'Walt Whitman'}] [[('id', 1), ('name', u'Charles Baudelaire')], [('id', 3), ('name', u'Paul Verlaine')], [('id', 2), ('name', u'Walt Whitman')]]
# Inline Formsets ############################################################ # Inline Formsets ############################################################