title: ModelForm validation in Django
body: <p>I'm trying to validate two forms on one page with single submit button. I don't really mind using either <code>forms.Form</code> or <code>forms.ModelForm</code> knowing the difference. <strong>However, when I submit the form for validation all data is being discarded and I get <code>This field is required</code> shouting at me from all fields except the <code>timeout</code> field as that one is optional and defaults to 10.</strong></p>
  
  <p>Please see my files:</p>
  
  <p>this view I'm using when trying to make it work with ModelForm class.
  When I'm trying to use just <code>Form</code> class I uncomment the lines and comment out the <code>.save()</code> lines:</p>
  
  <pre><code>def index(request):
  
      if request.method == 'POST':
          form_tc = TestCaseForm(request.POST)
          form_ts = TestCaseSuiteForm(request.POST)
          if form_tc.is_valid() and form_ts.is_valid():
              # TestCase.objects.create(
              #     name=form_tc.cleaned_data['name'],
              #     documentation=form_tc.cleaned_data['documentation'],
              #     steps=form_tc.cleaned_data['steps'],
              #     tags=form_tc.cleaned_data['tags'],
              #     setup=form_tc.cleaned_data['setup'],
              #     teardown=form_tc.cleaned_data['teardown'],
              #     template=form_tc.cleaned_data['template'],
              #     timeout=form_tc.cleaned_data.get('timeout', 10),
              # )
              #
              # TestSuite.objects.create(
              #     name=form_ts.cleaned_data['name'],
              #     documentation=form_ts.cleaned_data['documentation'],
              #     setup=form_ts.cleaned_data['setup'],
              #     teardown=form_ts.cleaned_data['teardown'],
              #     force_tags=form_ts.cleaned_data['force_tags'],
              #     timeout=form_ts.cleaned_data.get('timeout', 10),
              # )
              form_tc.save()
              form_ts.save()
              return redirect('/list')
  </code></pre>
  
  <p>forms.py:</p>
  
  <pre><code>class TestCaseForm(forms.ModelForm):
  
      name                    = forms.CharField(widget=forms.TextInput(attrs={
                                      'class': 'form-control',
                                      'placeholder': 'Enter Name'}), label='')
      documentation            = forms.CharField(widget=forms.TextInput(attrs={
                                      'class': 'form-control',
                              'placeholder': 'Enter Documentation'}), label='')
      steps                    = forms.CharField(widget=forms.TextInput(attrs={
                                      'class': 'form-control',
                                      'placeholder': 'Enter Steps'}), label='')
      tags                     = forms.CharField(widget=forms.TextInput(attrs={
                                      'class': 'form-control',
                                      'placeholder': 'Enter Tags'}), label='')
      setup                    = forms.CharField(widget=forms.TextInput(attrs={
                                      'class': 'form-control',
                                      'placeholder': 'Enter Setup'}), label='')
      teardown                 = forms.CharField(widget=forms.TextInput(attrs={
                                      'class': 'form-control',
                                      'placeholder': 'Enter Teardown'}), label='')
      template                 = forms.CharField(widget=forms.TextInput(attrs={
                                      'class': 'form-control',
                                      'placeholder': 'Enter Template'}), label='')
      timeout                  = forms.IntegerField(widget=forms.TextInput(attrs={
                                      'class': 'form-control',
                                      'placeholder': 'Enter Timeout (optional)'}),
                                       required=False, label='')
  
  class Meta:
      model = TestCase
      fields = [
          'name',
          'documentation',
          'steps',
          'tags',
          'setup',
          'teardown',
          'template',
          'timeout',
      ]
  </code></pre>
  
  <p>models:</p>
  
  <pre><code>name = models.CharField(max_length=200)
  documentation = models.CharField(max_length=2048, blank=True)
  steps = models.CharField(max_length=2048, blank=True)
  tags = models.CharField(max_length=200, blank=True)
  setup = models.CharField(max_length=2048, blank=True)
  teardown = models.CharField(max_length=2048, blank=True)
  template = models.CharField(max_length=200, blank=True)
  timeout = models.IntegerField(default=10)
  </code></pre>