[Answered ]-How do I access User Model field in the Serializer of extended User Model in Django Rest Framework?

1๐Ÿ‘

โœ…

If you look at the validated data you can see, the data belonging to MainRegisterSerializer serializer will be available with register key. And data belonging to RegisterSerializer serializer will be available with file key.

validated data :

{'register': OrderedDict([('username', 'test'), ('email', 'test@gmail.com'), ('password', 'test123')]), 'file': <InMemoryUploadedFile: filename.txt (text/csv)>}

so to access any fields for register you need to use:

validated_data['register']['username'], validated_data['register']['email'] ..etc.

for accessing the file you can use : validated_data['file']

๐Ÿ‘คLiquidDeath

Leave a comment