diff -r 232e190100e5 tests/modeltests/model_formsets/models.py
a
|
b
|
|
1 | 1 | from django.db import models |
| 2 | |
| 3 | try: |
| 4 | sorted |
| 5 | except NameError: |
| 6 | from django.utils.itercompat import sorted |
2 | 7 | |
3 | 8 | class Author(models.Model): |
4 | 9 | name = models.CharField(max_length=100) |
… |
… |
|
212 | 217 | |
213 | 218 | >>> AuthorFormSet = modelformset_factory(Author, max_num=2) |
214 | 219 | >>> formset = AuthorFormSet(queryset=qs) |
215 | | >>> formset.initial |
216 | | [{'id': 1, 'name': u'Charles Baudelaire'}, {'id': 3, 'name': u'Paul Verlaine'}] |
| 220 | >>> [sorted(x.items()) for x in formset.initial] |
| 221 | [[('id', 1), ('name', u'Charles Baudelaire')], [('id', 3), ('name', u'Paul Verlaine')]] |
217 | 222 | |
218 | 223 | >>> AuthorFormSet = modelformset_factory(Author, max_num=3) |
219 | 224 | >>> formset = AuthorFormSet(queryset=qs) |
220 | | >>> formset.initial |
221 | | [{'id': 1, 'name': u'Charles Baudelaire'}, {'id': 3, 'name': u'Paul Verlaine'}, {'id': 2, 'name': u'Walt Whitman'}] |
| 225 | >>> [sorted(x.items()) for x in formset.initial] |
| 226 | [[('id', 1), ('name', u'Charles Baudelaire')], [('id', 3), ('name', u'Paul Verlaine')], [('id', 2), ('name', u'Walt Whitman')]] |
| 227 | |
222 | 228 | |
223 | 229 | # Inline Formsets ############################################################ |
224 | 230 | |