Django Rest Framework DRF
Django REST framework is a powerful and flexible toolkit for building Web APIs.
Features
- Web browsable API
- Authentication policies
- Serialization
Commands
pip install pygments # for code highlighting
# Set up a new project with a single application
django-admin.py startproject tutorial . # Note the trailing '.' character
cd tutorial
django-admin.py startapp quickstart
-
Serialization
Model Serializers
class SnippetSerializer(serializers.ModelSerializer):
class Meta:
model = Snippet
fields = ('id', 'title', 'code', 'linenos', 'language', 'style')One nice property that serializers have is that you can inspect all the fields in a serializer instance, by printing its representation. Open the Django shell with
python manage.py shell
, then try the following:from snippets.serializers import SnippetSerializer
serializer = SnippetSerializer()
print(repr(serializer))HyperlinkedModelSerializer
-
Requests &Responses
-
Class-based views
-
Authentication & Permissions
https://nezhar.com/blog/django-rest-framework-permissions-in-depth
-
Relationships & hyperlinked APIs
-
Viewsets & routers
-
Schemas & client libraries
https://www.youtube.com/playlist?list=PLLxk3TkuAYnrO32ABtQyw2hLRWt1BUrhj