Это моя модель
class Business(models.Model):
business_type = models.ManyToManyField(BusinessType)
establishment_type = models.ForeignKey(EstablishmentType)
website = models.URLField()
name = models.CharField(max_length=64)
def __unicode__(self):
return self.name
на мой взгляд, я пытаюсь сохранить запись следующим образом:
business = BusinessForm(request.POST or None)
if business.is_valid():
busi = business.save(commit=False)
bt = BusinessType.objects.get(id=6)
busi.business_type = bt
et = EstablishmentType.objects.get(id=6)
busi.establishment_type = et
busi.save()
Однако это дает мне ошибку
'Business' instance needs to have a primary key value before a many-to-many relationship can be used.
Как мне сохранить это?