--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-fram...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/e2c5b788-21f5-41b7-b0a1-901f34675870%40googlegroups.com.
On Wed, Nov 13, 2019 at 6:49 PM Rob Deutsch <rob...@gmail.com> wrote:
One addendum: What I would like to do, from the public facing perspective, is change the Book ModelViewSet's POST event so that it includes the parameters include everything needed to create both a Book and an Author, but I still want it to return a Book model.--
On Thursday, November 14, 2019 at 10:44:38 AM UTC+11, Rob Deutsch wrote:I currently have a single Django model (lets call it Book) being made available via a ModelViewSet.I want to add a second model (call it Author) with a foreign key to Book.I want to insist that whenever a Book is created an Author is also created at the same time. It should not be possible to create a Book without an Author.I have determined that it's impossible to do this using Django in models.py. I know there must be a way to do it with DRF in serializers.py and/or views.py, but I've been unable to figure out the best way to do it. I've tried a few different things, but keep hitting nonsensical roadblocks, and I think that I conceptually just don't know the best way to assemble DRF to achieve this.Any suggestions?
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/e2c5b788-21f5-41b7-b0a1-901f34675870%40googlegroups.com.
On Wed, Nov 13, 2019 at 6:49 PM Rob Deutsch <rob...@gmail.com> wrote:
One addendum: What I would like to do, from the public facing perspective, is change the Book ModelViewSet's POST event so that it includes the parameters include everything needed to create both a Book and an Author, but I still want it to return a Book model.--
On Thursday, November 14, 2019 at 10:44:38 AM UTC+11, Rob Deutsch wrote:I currently have a single Django model (lets call it Book) being made available via a ModelViewSet.I want to add a second model (call it Author) with a foreign key to Book.I want to insist that whenever a Book is created an Author is also created at the same time. It should not be possible to create a Book without an Author.I have determined that it's impossible to do this using Django in models.py. I know there must be a way to do it with DRF in serializers.py and/or views.py, but I've been unable to figure out the best way to do it. I've tried a few different things, but keep hitting nonsensical roadblocks, and I think that I conceptually just don't know the best way to assemble DRF to achieve this.Any suggestions?
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/e2c5b788-21f5-41b7-b0a1-901f34675870%40googlegroups.com.
On Wed, Nov 13, 2019 at 6:49 PM Rob Deutsch <rob...@gmail.com> wrote:
One addendum: What I would like to do, from the public facing perspective, is change the Book ModelViewSet's POST event so that it includes the parameters include everything needed to create both a Book and an Author, but I still want it to return a Book model.--
On Thursday, November 14, 2019 at 10:44:38 AM UTC+11, Rob Deutsch wrote:I currently have a single Django model (lets call it Book) being made available via a ModelViewSet.I want to add a second model (call it Author) with a foreign key to Book.I want to insist that whenever a Book is created an Author is also created at the same time. It should not be possible to create a Book without an Author.I have determined that it's impossible to do this using Django in models.py. I know there must be a way to do it with DRF in serializers.py and/or views.py, but I've been unable to figure out the best way to do it. I've tried a few different things, but keep hitting nonsensical roadblocks, and I think that I conceptually just don't know the best way to assemble DRF to achieve this.Any suggestions?
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/e2c5b788-21f5-41b7-b0a1-901f34675870%40googlegroups.com.
On Wed, Nov 13, 2019 at 6:49 PM Rob Deutsch <rob...@gmail.com> wrote:
One addendum: What I would like to do, from the public facing perspective, is change the Book ModelViewSet's POST event so that it includes the parameters include everything needed to create both a Book and an Author, but I still want it to return a Book model.--
On Thursday, November 14, 2019 at 10:44:38 AM UTC+11, Rob Deutsch wrote:I currently have a single Django model (lets call it Book) being made available via a ModelViewSet.I want to add a second model (call it Author) with a foreign key to Book.I want to insist that whenever a Book is created an Author is also created at the same time. It should not be possible to create a Book without an Author.I have determined that it's impossible to do this using Django in models.py. I know there must be a way to do it with DRF in serializers.py and/or views.py, but I've been unable to figure out the best way to do it. I've tried a few different things, but keep hitting nonsensical roadblocks, and I think that I conceptually just don't know the best way to assemble DRF to achieve this.Any suggestions?
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/e2c5b788-21f5-41b7-b0a1-901f34675870%40googlegroups.com.
On Wed, Nov 13, 2019 at 6:49 PM Rob Deutsch <rob...@gmail.com> wrote:
One addendum: What I would like to do, from the public facing perspective, is change the Book ModelViewSet's POST event so that it includes the parameters include everything needed to create both a Book and an Author, but I still want it to return a Book model.--
On Thursday, November 14, 2019 at 10:44:38 AM UTC+11, Rob Deutsch wrote:I currently have a single Django model (lets call it Book) being made available via a ModelViewSet.I want to add a second model (call it Author) with a foreign key to Book.I want to insist that whenever a Book is created an Author is also created at the same time. It should not be possible to create a Book without an Author.I have determined that it's impossible to do this using Django in models.py. I know there must be a way to do it with DRF in serializers.py and/or views.py, but I've been unable to figure out the best way to do it. I've tried a few different things, but keep hitting nonsensical roadblocks, and I think that I conceptually just don't know the best way to assemble DRF to achieve this.Any suggestions?
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/e2c5b788-21f5-41b7-b0a1-901f34675870%40googlegroups.com.
On Wed, Nov 13, 2019 at 6:49 PM Rob Deutsch <rob...@gmail.com> wrote:
One addendum: What I would like to do, from the public facing perspective, is change the Book ModelViewSet's POST event so that it includes the parameters include everything needed to create both a Book and an Author, but I still want it to return a Book model.--
On Thursday, November 14, 2019 at 10:44:38 AM UTC+11, Rob Deutsch wrote:I currently have a single Django model (lets call it Book) being made available via a ModelViewSet.I want to add a second model (call it Author) with a foreign key to Book.I want to insist that whenever a Book is created an Author is also created at the same time. It should not be possible to create a Book without an Author.I have determined that it's impossible to do this using Django in models.py. I know there must be a way to do it with DRF in serializers.py and/or views.py, but I've been unable to figure out the best way to do it. I've tried a few different things, but keep hitting nonsensical roadblocks, and I think that I conceptually just don't know the best way to assemble DRF to achieve this.Any suggestions?
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/e2c5b788-21f5-41b7-b0a1-901f34675870%40googlegroups.com.
On Wed, Nov 13, 2019 at 6:49 PM Rob Deutsch <rob...@gmail.com> wrote:
One addendum: What I would like to do, from the public facing perspective, is change the Book ModelViewSet's POST event so that it includes the parameters include everything needed to create both a Book and an Author, but I still want it to return a Book model.--
On Thursday, November 14, 2019 at 10:44:38 AM UTC+11, Rob Deutsch wrote:I currently have a single Django model (lets call it Book) being made available via a ModelViewSet.I want to add a second model (call it Author) with a foreign key to Book.I want to insist that whenever a Book is created an Author is also created at the same time. It should not be possible to create a Book without an Author.I have determined that it's impossible to do this using Django in models.py. I know there must be a way to do it with DRF in serializers.py and/or views.py, but I've been unable to figure out the best way to do it. I've tried a few different things, but keep hitting nonsensical roadblocks, and I think that I conceptually just don't know the best way to assemble DRF to achieve this.Any suggestions?
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+unsub...@googlegroups.com.
class AlbumSerializer(serializers.ModelSerializer):
tracks = TrackSerializer(many=True, write_only=True)