Correcciones en nombre sea de dios

This commit is contained in:
fjrodriguez
2023-04-12 08:07:06 -06:00
parent 4fe84dbfb6
commit 21b92f248e
6 changed files with 48 additions and 15 deletions

View File

@@ -44,13 +44,13 @@ class DeviceSerializer(serializers.ModelSerializer):
& Q(macAddress__icontains=mac_address)
& Q(database=self.context['request'].data.get('database'))
)
print('existing_devices', existing_devices)
if existing_devices.exists():
# A device with the same macAddress already exists for the given sistema and client
# Get the number of existing devices and add 1 to create a new suffix
suffix = existing_devices.count() + 1
mac_address += f'_{suffix}'
print('suffix mac_address',mac_address)
validated_data['macAddress']= mac_address
return super().create(validated_data)