class Sample(models.model):
sampleID = models.AutoField(primary_key=True)
something = models.IntegerField()
.
.
.
def save(self, *args, **kwargs):
is_new = self.pk is None
super(Sample, self).save(*args, **kwargs)
if is_new:
alpha = AnotherSample()
alpha.asampleID = self.pk
alpha.say = "Lolz"
alpha.save()
サンプルのAnotherSampleの参照キーに主キーを割り当てることができません。それはいつも言う
Cannot assign "1L": "AnotherSample.asampleID" must be a "Sample" instance.