Models:
class Author(Base):
name = models.CharField(max_length=100, unique=True)
class Book(Base):
name = models.CharField(max_length=100, unique=True)
class AuthorBookAssn(Base):
author = models.ForeignKey(Author, on_delete=models.PROTECT)
book = models.ForeignKey(Book, on_delete=models.CASCADE)
I have an api to create a book, and along with the book data we would also get a list of author ids how should the serializer field be created such that it is a list of ids.
for example:
[1, 2, 3]
This field would not be present in any models we only need to use these fields to create records in the AuthorBookAssn table.