I have a model with many foreing keys. I want to do a POST with only ids and recieve a response with depth 1. When I set depth=1 it´s doesn´t work.
class State(models.Model):
name = models.CharField(max_length=255)
class City(models.Model):
state = models.ForeingKey(State, on_delete=models.PROTECT)
name = models.CharField(max_length=255)
class CitySerializer(serializers.ModelSerializer):
class Meta:
model = City
fields = '__all__'
I wanna post some like this
{
"state":1,
"name":"City Name"
}
And get
{
"id":1,
"name":"City Name",
"state":{
"id":1,
"name": "State Name"
}
}