-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Django RestFramework 사용하기 #35
Comments
# [PROJECT_NAME]/settings.py
INSTALLED_APP = [
... ,
'rest_framework' # 추가
] |
# [APP_NAME]/seriallizers.py (새로 생성)
# 여기서 Task는 임의로 만든 모델임
from rest_framework import serializers
from .models import Task
class TaskSerializers(serializers.ModelSerializer):
class Meta:
model = Task
fields = '__all__' |
# [APP_NAME]/views.py
from rest_framework import viewsets
from django_filters.rest_framework import DjangoFilterBackend
from .models import Product
from .serializers import ProductSerializers
class ProductViewSet(viewsets.ModelViewSet):
queryset = Product.objects.all()
serializer_class = ProductSerializers
filter_backends = (DjangoFilterBackend, )
filter_fields = '__all__'
# 여기서 list, retrieve 함수 등을 정의하는 것으로 override 가능함 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No description provided.
The text was updated successfully, but these errors were encountered: