In [1]: from songs.models import Artist, Song
In [2]: artists = Artist.objects.bulk_create([
...: Artist(name="Dio"),
...: Artist(name="Black Sabbath"),
...: Artist(name="Pink Floyd"),
...: ])
# save() included
In [3]: artists
Out[3]: [<Artist: Dio>, <Artist: Black Sabbath>, <Artist: Pink Floyd>]
In [4]: a1 = artists[0]
In [5]: a2 = artists[1]
In [6]: a3 = artists[2]
In [7]: songs = Song.objects.bulk_create([
...: Song(title="Holy Diver", artist=a1),
...: Song(title="Rainbow In The Dark", artist=a1),
...: Song(title="A National Acrobat", artist=a2),
...: Song(title="Paranoid", artist=a2),
...: Song(title="Children Of The Grave", artist=a2),
...: Song(title="Shine On You Crazy Diamond", artist=a3),
...: ])
# not artist="Dio"
# ValueError: Cannot assign "'Dio'": "Song.artist" must be a "Artist" instance.
-
Notifications
You must be signed in to change notification settings - Fork 0
acuglar/Kenziefy
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published