Answer the question
In order to leave comments, you need to log in
How to change update method for nested serializer?
How to write update() correctly, I have a large number of fields, isn't there another method?
class ProfileSerializer(serializers.ModelSerializer):
legal = LegalSerializer(many=False)
tech = TechSerializer(many=False)
marketing = MarketingSerializer(many=False)
finance = FinanceSerializer(many=False)
translation_and_content = ContentSerializer(many=False)
interests = InterestsSerializer(many=False)
langs = LanguageSerializer(many=False)
socials = SocialSerializer(many=True)
class Meta:
model = get_user_model()
exclude = ('is_staff', 'is_active', 'date_joined', 'password',
'last_login', 'user_permissions', 'groups', 'is_superuser')
Answer the question
In order to leave comments, you need to log in
legal = validated_data.get('legal')
instance.legal.legal_audit = legal.get('legal_audit')
instance.legal.taxation_ico = legal.get('taxation_ico')
instance.legal.security_regulation = legal.get('security_regulation')
instance.legal.company_setup = legal.get('company_setup')
instance.legal.save()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question