Let's imagine we have next models:
class Radio(models.Model):
name = models.CharField(...)
class Artist(models.Model):
name = models.CharField(...)
class Song(models.Model):
title = models.CharField(...)
artist = models.ForeignKey(Artist, ...)
class Reproduction(models.Model):
song = models.ForeignKey(Song...)
radio = models.ForeignKey(Radio...)
date = models.DateTimeField(...)
How should I create my serializer and view if I will receive in a POST:
title: "Song title", artist:"Artist name", radio:"Radio name", date:"Reproduction date" and it's needed to create the artist and the song if they don't exist.
Thank you.