rancher add province & city to serializer

This commit is contained in:
2025-08-03 16:15:12 +03:30
parent ebb8f3f6af
commit 3bb528f4f1
3 changed files with 17 additions and 2 deletions

View File

@@ -14,7 +14,7 @@
</component>
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.10 (bazrasienv)" jdkType="Python SDK" />
<orderEntry type="jdk" jdkName="Python 3.10 (env)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="PyDocumentationSettings">

2
.idea/misc.xml generated
View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (bazrasienv)" project-jdk-type="Python SDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (env)" project-jdk-type="Python SDK" />
</project>

View File

@@ -31,3 +31,18 @@ class RancherSerializer(serializers.ModelSerializer):
class Meta:
model = Rancher
fields = '__all__'
def to_representation(self, instance):
representation = super().to_representation(instance)
representation['province'] = {
'id': instance.province.id,
'name': instance.province.name
}
representation['city'] = {
'id': instance.city.id,
'name': instance.city.name
}
return representation