Changes between Initial Version and Version 2 of Ticket #28799
- Timestamp:
- Nov 16, 2017, 4:41:12 AM (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #28799 – Description
initial v2 3 3 {{{ 4 4 from django.db import models 5 from django.forms.models import modelformset_factory 6 from django.test import TestCase 5 7 6 from django.test import TestCase 7 from django.forms.models import modelformset_factory 8 9 class Price(models.Model): 10 quantity = models.PositiveIntegerField() 8 class Author(models.Model): 9 name = models.CharField(max_length=100) 11 10 12 11 class ModelFormsetTest(TestCase): … … 15 14 'form-TOTAL_FORMS': '2', 16 15 'form-INITIAL_FORMS': '0', 17 'form-0-quantity': '1', 16 'form-0-name': 'a', 17 'form-1-name': 'b', 18 18 } 19 19 20 FormSet = modelformset_factory( Price, fields=('quantity',), min_num=1, validate_min=True)21 formset = FormSet(data , initial=[{'quantity': 1}])20 FormSet = modelformset_factory(Author, min_num=2, exclude=(), validate_min=True) 21 formset = FormSet(data=data, queryset=Author.objects.none(), initial=[{'name': 'a'}]) 22 22 self.assertTrue(formset.is_valid()) 23 self.assertTrue(len(formset.save()), 2) 23 24 }}} 24 25