JaqiKal / pixavibe-frontend

The Pixavibe is a social media website for sharing photos. Created as part of my full-stack portfolio project 5 for the Code Institute diploma in full stack software development.
0 stars 0 forks source link

[BUG] Post detail CRUD lost #66

Closed JaqiKal closed 1 month ago

JaqiKal commented 1 month ago

Describe the bug Logged in Post owner could not update/delete own post

To Reproduce Steps to reproduce the behavior: Log in cklick on card, no dropdown menu.

Expected behavior Logged in user shall be able to delete or update post details.

Screenshots N/A

Desktop / Smartphone (please complete the following information):**

JaqiKal commented 1 month ago

Solved with commit 47: 80a9cc6 in pixavibe-api.

Use PostCreateUpdateSerializer for PUT/PATCH requests Use correct serializer for update and retrieve, ensures appropriate handling of post data based on request   Add below snippet to class PostDetail(generics.RetrieveUpdateDestroyAPIView)

    def get_serializer_class(self):
        if self.request.method in ['PUT', 'PATCH']:
            return PostCreateUpdateSerializer
        return PostSerializer