django foreign key save

后端 未结 5 841
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-18 21:25

I have models for eg like this.

class Mp3(models.Model):
    title=models.CharField(max_length=30)
    artist=models.ForeignKey(\'Artist\')

5条回答
  •  無奈伤痛
    2020-12-18 22:07

    The answer would be:

    newMp3=Mp3(title="sth", artist=the_artist)
    

    where 'the_artist' is an actual instance of an Artist

提交回复
热议问题