fix update user data bug
This commit is contained in:
@@ -97,6 +97,12 @@ class UserSerializer(serializers.ModelSerializer):
|
||||
extra_kwargs = {
|
||||
'password': {
|
||||
'required': False
|
||||
},
|
||||
'username': {
|
||||
'required': False
|
||||
},
|
||||
"national_code": {
|
||||
'required': False
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,15 +110,16 @@ class UserSerializer(serializers.ModelSerializer):
|
||||
""" Custom output """
|
||||
|
||||
representation = super().to_representation(instance)
|
||||
if instance.bank_information.all():
|
||||
representation['bank_account'] = BankAccountSerializer(
|
||||
instance.bank_information.all(), many=True
|
||||
).data
|
||||
if isinstance(instance, User):
|
||||
if instance.bank_information.filter().exists():
|
||||
representation['bank_account'] = BankAccountSerializer(
|
||||
instance.bank_information.all(), many=True
|
||||
).data
|
||||
|
||||
if instance.city:
|
||||
representation['city_name'] = instance.city.name
|
||||
if instance.province:
|
||||
representation['province_name'] = instance.province.name
|
||||
if instance.city:
|
||||
representation['city_name'] = instance.city.name
|
||||
if instance.province:
|
||||
representation['province_name'] = instance.province.name
|
||||
|
||||
return representation
|
||||
|
||||
|
||||
Reference in New Issue
Block a user