Form object has no attribute 'save_m2m' when overriding the save method

Viewed 148

I made a custom Admin form in which I overrode the save method:

def save(self, commit=True):
     product = Product.objects.create(
            title=self.data.get("title"),
            user=USER_MODEL.objects.get(id=self.data.get("user")),
            date=date,
      )
      File.objects.create(
                file=self.data.get("file_xls"),
                product=product,
                user=USER_MODEL.objects.get(id=self.data.get("user")),
                date=date,
      )
      ProductOption.objects.create(
                product=product, file=xls_file, name=ProductOption.XLS
      )

      return product

The problem now is that I get a 'ProductForm' object has no attribute 'save_m2m' even though the model doesn't have any M2M fields.

0 Answers
Related