HackSoftware / Django-Styleguide

Django styleguide used in HackSoft projects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

API response structure

RadoRado opened this issue · comments

It's a good idea to add few words about how to structure API responses so they are consistent.

This also includes:

  • Working with filters
  • Pagination
  • How to properly format error responses

@RadoRado Do you have any examples of how pagination and filters are performed in your projects.

Do you handle these within your selectors by passing arguments or do implement GenericAPIView in your api so you can use the built in pagination and filtering mechanism and use your selectors within the get_queryset

cheers

@RTS340 Here's an example of a list API with filtering + pagination, matching the styleguide: HackSoftware/Django-Styleguide-Example#11

It's still work in progress (need to write tests), but the general idea is there.