DRF steps
Fri Jul 30 2021 13:21:51 GMT+0000 (Coordinated Universal Time)
Saved by
@white_hole
pip install djangorestframework
#serializers.py
from snips.models import *
from rest_framework import serializers
class LanguageSerializer(serializers.ModelSerializer):
class Meta:
model = Language
fields = '__all__'
extra_kwargs = {
'id': {'read_only': False, 'required': False},
'language': {'validators': []}
}
#views.py
from rest_framework.decorators import api_view
from rest_framework.response import Response
from main.models import *
from api.serializers import *
from rest_framework import status
content_copyCOPY
Comments