20 lines
496 B
Python
20 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)
|