poulpe/api/event/views.py
2017-07-18 17:48:59 +02:00

19 lines
496 B
Python

from django.contrib.auth import get_user_model
from rest_framework.viewsets import ModelViewSet
from api.event.serializers import EventSerializer
from event.models import Event
User = get_user_model()
class EventViewSet(ModelViewSet):
"""
This viewset automatically provides `list` and `detail` actions.
"""
queryset = Event.objects.all()
serializer_class = EventSerializer
def perform_create(self, serializer):
serializer.save(created_by=self.request.user)