When I looked it up, it seems that I can set it uniquely using Key_name, but I didn't feel like I tried it, so I applied select and saved it if there was no match.
def SaveMusic(minfo,rank_info):
MusicModel = Music()
MusicModel.category = rank_info['category']
MusicModel.title = minfo['title']
MusicModel.artistName = minfo['artist']
entity = Music.gql("WHERE title = :title", title=minfo['title'])
if entity is None:
MusicModel.put()
The title field is not duplicated.
Recommended Posts