Django REST framework
The source repository is https://github.com/ccapeng/bookstore_api
Installation
pip install djangorestframework
In the regular django, you need to implement view in order to output data. with REST framework, only need to implement serializer
book.serializers.py
in order to save data. And, register url inbook.urls.py
When server startup, then you can view api in http://127.0.0.1:8000/api/category/ http://127.0.0.1:8000/api/publisher/ http://127.0.0.1:8000/api/author/ http://127.0.0.1:8000/api/book/Snake-case to camel-case Python is a language like all against c syntax, no curly brace block match and use snake-case for the variables. In general, we also use camel-case in javascript, json. The following implementation totally take the extra translation.
Add
This parser was copied from https://gist.github.com/vbabiy/5842073.
So in the settings.py, also update:
To bypass cross Origin, you need to add the following middleware implementation into order to have browser accept the cross site permission. Middleware implement at bookstore_api.corsapp.middleware.py
Last updated