title: Django error: The Items could not be created because the data didn't validate
body: <p>I get the following error:
  <strong>ValueError at /create-items/
  The Items could not be created because the data didn't validate.</strong>, and can't find out what the issue is...</p>
  <p>Views.py</p>
  <pre><code>def createMulitpleItemsPage(request):
      currency = '€'
  
      ItemFormSet = modelformset_factory(Items, form=CreateItemFormset, extra=1)
      qs = Items.objects.none()
      user = request.user.profile
      formset = ItemFormSet(request.POST or None, queryset=qs, form_kwargs={'user': user})
  
      # Create multiple items
      if request.method == 'GET':
          user = request.user.profile
          ItemFormSet = modelformset_factory(Items, form=CreateItemFormset, extra=1)
          qs = Items.objects.none()
          formset = ItemFormSet(request.POST or None, queryset=qs, form_kwargs={'user': user})
  
      context = {'formset': formset}
  
      if request.method == 'POST':
          print('printing POST: ', request.POST)
          print('printing Errors: ', formset.errors)
  
          if formset.is_valid():
              formset = CreateItemFormset(user=request.user.profile, data=request.POST)
              parent = formset.save(commit=False)
              parent = formset.save()
              for form in formset:
                  newitems = form.save(commit=False)
                  newitems.user = request.user.profile
                  newitems.save()
              return redirect('items')
  
      return render(request, 'base/mass_create_items.html', context)
  </code></pre>
  <p>Forms.py</p>
  <pre><code>class CreateItemFormset(ModelForm):
      def __init__(self, user, *args, **kwargs):
          super(CreateItemFormset, self).__init__(*args, **kwargs)
          qs = Categories.objects.filter(user=user)
          self.fields['item_category'] = ModelChoiceField(queryset=qs)
  
      class Meta:
          model = Items
          fields = ['item_name', 'item_category', 'item_start_date', 'item_end_date', 'item_purchase_price', 'item_rest_value']
  </code></pre>
  <p>Models.py</p>
  <pre><code>class Items(models.Model):
      user = models.ForeignKey(Profile, on_delete=models.CASCADE, null=True, blank=True)
      item_name = models.CharField(max_length=200, null=False, blank=False)
      item_category = models.ForeignKey(Categories, null=True, blank=True, on_delete=models.SET_NULL)
      item_created_at = models.DateTimeField(auto_now_add=True, null=True, blank=False)
      item_updated_at = models.DateTimeField(auto_now=True, null=True, blank=False)
      item_start_date = models.DateField(null=True, blank=False)
      item_end_date = models.DateField(null=True, blank=False)
      item_purchase_price = models.FloatField(null=True, blank=False)
      item_rest_value = models.FloatField(default=0, null=True, blank=False)
      item_saving_goal = models.FloatField(default=0, null=True, blank=False)
      item_date_delta = models.FloatField(default=0, null=True, blank=False)
      item_days_passed = models.FloatField(default=0, null=True, blank=False)
      item_currently_saved = models.FloatField(default=0, null=True, blank=False)
      item_percentage_saved = models.FloatField(default=0.01, null=True, blank=False)
      item_monthly_saving = models.FloatField(default=0, null=True, blank=False)
  
      def save(self, *args, **kwargs):
          self.item_saving_goal = self.item_purchase_price - self.item_rest_value
          self.item_date_delta = (self.item_end_date.year - self.item_start_date.year) * 12 + ( self.item_end_date.month - self.item_start_date.month )
          self.item_days_passed = (date.today().year - self.item_start_date.year) * 12 + ( date.today().month - self.item_start_date.month )
          self.item_currently_saved = self.item_saving_goal * (self.item_days_passed / self.item_date_delta )
          self.item_percentage_saved = self.item_currently_saved / self.item_saving_goal * 100
          self.item_monthly_saving = self.item_saving_goal / self.item_date_delta
          super().save(*args, **kwargs)
  </code></pre>
  <p>Error looks like this:</p>
  <blockquote>
  <p>Internal Server Error: /create-items/
  Traceback (most recent call last):
  File &quot;/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/django/core/handlers/exception.py&quot;,
  line 47, in inner
  response = get_response(request)
  File &quot;/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/django/core/handlers/base.py&quot;,
  line 181, in _get_response
  response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File &quot;/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/django/contrib/auth/decorators.py&quot;,
  line 21, in _wrapped_view
  return view_func(request, *args, **kwargs)
  File &quot;/Users/jelledekker/Library/Mobile Documents/com~apple~CloudDocs/Django/Aurelian web/base/views.py&quot;, line
  304, in createMulitpleItemsPage
  parent = formset.save(commit=False)
  File &quot;/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/django/forms/models.py&quot;,
  line 458, in save
  raise ValueError(
  ValueError: The Items could not be created because the data didn't validate.</p>
  </blockquote>