So, this is how i have implemented the class:
class VenueSerializer(serializers.ModelSerializer):
city = serializers.StringRelatedField(many=True)
class Meta:
model = Venue
fields = '__all__'
def create(self, validated_data):
venue = Team(
name=validated_data['name']
#I know this is wrong but i just wanted to demonstrate what is it that i need to get done
#city is the foreign key referencing to the model City
city=validated_data['city']
)
venue.save()
return venue
So i have a model for venues, and each venue has to be associated with the model city. I am new to the REST Framework and i can't figure out a way to create an instance of the venue model while setting the value of the city field. Can someone please help me with this?
Than you