-
Notifications
You must be signed in to change notification settings - Fork 6
Server side API management
Models are defined in a model.py
if there are few. If your module can be split in several sub-modules, please make different files and include them in a model
folder. The files will then be loaded in the __init__.py
file.
A good example of that is given throughout the "associations" module.
A serializer converts models to JSON and vice-versa. They should be defined in a serializer
folder or file, according to what's been said in the previous section.
One can define different serializers for different uses, for example for a list view or a detail view.
Find more information at http://www.django-rest-framework.org/api-guide/serializers/
The view gets the request, loads the models, serializes it and sends the response. It's pretty straightforward. Once more, please use the same file convention as before, and read the doc at : http://www.django-rest-framework.org/api-guide/views/
Last but not least, you need to add your view to the router, which is currently defined in api/urls.py
. Maybe it should not include all the routes. Feel free to refactor it a little 🙂
You can filter API results through GET parameters. For instance api/v1/rest/member?city=Gotham
will return all the users whose city of origin is Gotham.
You can use very powerful url filtering in the doc https://github.com/miki725/django-url-filter. The module is already installed, you only have to load it.
This is a living document, YOU should feel responsible for updating it.
- Code workflow
- Tests
- Project management (issues, PR, reviews)