Event API & User Event view
This commit is contained in:
24
eventplanner/serializers.py
Normal file
24
eventplanner/serializers.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from rest_framework import serializers
|
||||
from models import EventParticipation
|
||||
|
||||
|
||||
|
||||
|
||||
class ParticipationSerializer(serializers.ModelSerializer):
|
||||
event = serializers.PrimaryKeyRelatedField( many=False, read_only = False )
|
||||
musician = serializers.Field( source='get_musician_username' )
|
||||
# musician = serializers.PrimaryKeyRelatedField( many=False, read_only = False )
|
||||
|
||||
def get_identity(self, data):
|
||||
""" This hook is required for bulk update. """
|
||||
try:
|
||||
return ( data.get('event', None), data.get('musician') )
|
||||
except AttributeError:
|
||||
return None
|
||||
|
||||
class Meta:
|
||||
model = EventParticipation
|
||||
fields = ('event', 'musician', 'status', 'comment')
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user