Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Rabid DRF Learning #24

Open
fazledyn opened this issue Aug 10, 2020 · 1 comment
Open

Rabid DRF Learning #24

fazledyn opened this issue Aug 10, 2020 · 1 comment
Labels
question Further information is requested

Comments

@fazledyn
Copy link

fazledyn commented Aug 10, 2020

Added Serializer and ViewSet for PostComment model in branch

Did not test yet. Clueless about how to do it. I had some questions by the way.

  1. We don't need to create serializer for through relationship classes, do we?

  2. I read documentation of DRF. But bujhlam na ForeignKey/ManyToMany field er jonno ki alada kore serializer likhte hobe naki. Or should I just add HyperLinkedField for them ?

  3. In coreapp/models.py/line 135: PostComment Model
    Ekhane PostComment class er sathe Reacts er ManyToMany relationship keno ?
    OneToMany/ManyToOne howar kotha na ?

Tagging @Subangkar Bhai

@fazledyn fazledyn added the question Further information is requested label Aug 10, 2020
@Subangkar
Copy link
Member

@fazledyn
First of all, PostComment Model has a rough simple design. But we can start with that. Now for your queries,
1&2. You need to use custom serializer for ForeignKey/ManyToMany if you want to have additional fields for that ForeignKey/ManyToMany attribute instead of just primary key.
3. PostComment's reacts is a relation between User & PostComment which is m2m.

But start with a simpler one. For now, implement only comment part just like PostReaction which should return json like:

{
 comment: text,  
 time: comment-time,  
 user: user-hyperlink like PostReactionSerializer,  
 post: post-hyperlink like PostReactionSerializer,  
}

Try to go thru the following steps for simplicity:

  1. set the nested url acc to this card like PostReaction urls
  2. implement the serializer & viewset to create/edit comments like above setting user/post properly like PostReaction
  3. Handle comment edit permission properly with DRF Permissions

Leave Comment Reaction/Reply parts for now. We will deal that later
Use Postman for testing.
We currently have two users: admin/admin, intruder/123. You can add new user following swagger doc or feel free to use these ones for testing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants