[Fixed]-Inserting data into a Table row using Django ORM

1👍

you can get an instance of saved object by

  model_obj = Album.objects.get(artist ="Madona")

and after getting an object you can create Song object and save it.

  song_obj = Song(album=model_obj, title="SongA")
  song_obj.save()
👤Sagar

0👍

The foreign key needs the pk of the object. Use a.id instead of a.

Leave a comment