I have these serializers:
class OneSerializer(serializers.ModelSerializer):
class Meta:
model = OneModel
fields = ['time_column', 'event_column']
class TwoSerializer(serializers.ModelSerializer):
survival_columns = OneSerializer(many=True, required=False)
class Meta:
model = UserFile
fields = ['id', 'name', 'survival_columns']
Now in the create
method I'm trying to retrieve survival_columns
values from validated_data
but it's not present! If I print the POST data the field and values appear correctly:
def create(self, validated_data):
print(self.context['request'].POST) # <QueryDict: {'name': ['Datos Clinicos de prueba.csv'], 'survival_columns': ['{"event_column":"Prueba","time_column":"prueba"}']}>
print(validated_data) # {'name': 'Datos Clinicos de prueba.csv'}
Why is the field survival_columns
being filtered from the request?
question from:
https://stackoverflow.com/questions/65890892/django-field-not-appearing-in-validated-data-but-its-in-request 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…