Singe CRUD / request->response Operation two serializers · encode/django-rest-framework · Discussion #9630 · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

Singe CRUD / request->response Operation two serializers #9630

Discussion options

You must be logged in to vote

I had this problem a few times and there are a few ways to solve the problem, depending on how much your request schema differs from your response schema. Generally speaking, I think it's a good idea to minimise the differences. I'll describe a few options I've adopted over time.

Example

Let's use a simple BlogPost model in an blogging application:

class BlogPost(models.Model):
    author = models.ForeignKey("auth.User", on_delete=models.CASCADE)
    title = models.CharField(max_length=255)
    body = models.TextField()
    created_at = models.DateTimeField(auto_now_add=True)

When a post of created, the author provides the title and body, and the other fields as derived from the request. …

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@jon-nfc
Comment options

@browniebroke
Comment options

@jon-nfc
Comment options

@wdifruscio
Comment options

Answer selected by jon-nfc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.