We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
this code
class Author(models.Model): name =models.CharField(max_length=255) class Book(models.Model): name=models.CharField(max_length=255) author = models.ForeignKey(Author, on_delete=models.CASCADE, null=True, db_index=False) class BookSchema(ModelSchema): class Meta: model = Book fields = '__all__' @router.put("/books/{id}/", response=BookSchema) def put_book(request, pk: int, data: BookSchema): return Book.objects.get(id=id) @router.get("/books/{id}/", response=BookSchema) def get_book_detail(request, id: int): return Book.objects.get(id=id)
gives this schemas
just change the order of routes
class Author(models.Model): name =models.CharField(max_length=255) class Book(models.Model): name=models.CharField(max_length=255) author = models.ForeignKey(Author, on_delete=models.CASCADE, null=True, db_index=False) class BookSchema(ModelSchema): class Meta: model = Book fields = '__all__' @router.get("/books/{id}/", response=BookSchema) def get_book_detail(request, id: int): return Book.objects.get(id=id) @router.put("/books/{id}/", response=BookSchema) def put_book(request, pk: int, data: BookSchema): return Book.objects.get(id=id)
and you get a different schema
The text was updated successfully, but these errors were encountered:
when having only a post route
@router.put("/books/{id}/", response=create_schema(Book)) def put_book(request, pk: int, data: BookSchema): return Book.objects.get(id=id)
doest produce the same response schema as
@router.put("/books/{id}/", response=BookSchema) def put_book(request, pk: int, data: BookSchema): return Book.objects.get(id=id)
The inputschema and the response shema should contain author, not author_id.
Sorry, something went wrong.
No branches or pull requests
this code
gives this schemas
just change the order of routes
and you get a different schema
The text was updated successfully, but these errors were encountered: