from rest_framework import mixins
from rest_framework import generics
from students.models import Student
from students.serializer import StudentSerializer
class StudentView(mixins.CreateModelMixins)
queryset = Student.object.all()
serializer_class = StudentSerializer
Mixins
The mixin classes provide the actions that are used to provide the basic view behavior. Note that the mixin classes provide action methods rather than defining the handler methods, such as .get() and .post(), directly. This allows for more flexible composition of behavior.
The mixin classes can be imported from rest_framework.mixins.
출처 : drf 공식문서
믹스인 클래스는 자주 사용되는 view 패턴들을 제공한다.
def post() , def delete() 같은 것들을 그냥 쉽게 쓰기 편하게 모아놓았기 때문에
이걸 사용한다면 코드가 많이 짧아진다.