HackSoftware / Django-Styleguide

Django styleguide used in HackSoft projects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Handling with complicated data & nested resources

Mateusz-Slisz opened this issue · comments

Hello, first of all, I think you have been doing a great job with styles for Django. However, I'm curious what do you think about the below concepts:

  1. Large serialization, exactly creating/updating objects from complicated data. As I can see there is an example of very simple cases. I would like to know how you handle complicated services with many arguments (maybe you use domain entities to simplify it?) and how communication between these services looks.
  2. Nested resources, e.g. /courses/1/comments/create for creating.
    Do you allow to use it in your company? If so, how would it look like from the serializer/validation/service side?

Adding a special section for the above concepts and similar would be helpful for me and I hope for others too.

@Mateusz-Slisz Thanks for the question.

Few points:

  1. If you use non-plain serializer for InputSerializer, this sounds like you plan to use that serializer to create the object. This is something that we don't do & rather use the service layer for object creation. That said - I see no reason to use ModelSerializer for that.
  2. If you have a service with many arguments, you might take the approach that's discussed here - #57
  3. URL patterns are always up to the developers to decide. It's important to be consistent there. We usually follow this pattern - https://github.com/HackSoftware/Django-Styleguide#urls - but again - it can vary from project to project.

My answers are a bit vague and generic. If you need more detailed answers - please - provide more context in the questions / code examples 🖖

Closing this for now 🙌