Вставка uuid-данных в uuid-поле приводит к ошибке
При попытке создать объект, вставляющий uuid-данные в uuid-поле, выдается ошибка Что это за ошибка, которую я не смог найти в своем коде, и какое может быть решение для устранения ошибки, когда uuid-поле не принимает uuid-данные
def create(self, validated_data):
products_data = validated_data.pop('products')
kitchen_order = KitchenOrder.objects.create(**validated_data)
for product_data in products_data:
modifiers_data = product_data.pop('modifiers', [])
print(f"product id: {product_data}")
kitchen_order_item = KitchenOrderItem.objects.create(
kitchen_order=kitchen_order,
product_id=product_data.get('product_id'),
quantity=product_data['quantity'],
note=product_data['note']
)
for modifier_data in modifiers_data:
KitchenOrderItem.objects.create(
kitchen_order=kitchen_order,
modifier=kitchen_order_item,
product_id=modifier_data.get('product_id'),
quantity=modifier_data['quantity'],
note=modifier_data['note']
)
return kitchen_order
"products": [
{
"product_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"quantity": 2,
"note": "safs",
"modifiers": [
{
"product_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"quantity": 2,
"note": "safs"
}
]
}
]
При вставке вышеуказанной ошибки выдается ошибка вида
updated = self._save_table(
File "/home/suraj/Desktop/backend-third-party-integration/venv/lib/python3.10/site-packages/django/db/models/base.py", line 1067, in _save_table
results = self._do_insert(
File "/home/suraj/Desktop/backend-third-party-integration/venv/lib/python3.10/site-packages/django/db/models/base.py", line 1108, in _do_insert
return manager._insert(
File "/home/suraj/Desktop/backend-third-party-integration/venv/lib/python3.10/site-packages/django/db/models/manager.py", line 87, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/suraj/Desktop/backend-third-party-integration/venv/lib/python3.10/site-packages/django/db/models/query.py", line 1845, in _insert
return query.get_compiler(using=using).execute_sql(returning_fields)
File "/home/suraj/Desktop/backend-third-party-integration/venv/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 1823, in execute_sql
cursor.execute(sql, params)
File "/home/suraj/Desktop/backend-third-party-integration/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 122, in execute
return super().execute(sql, params)
File "/home/suraj/Desktop/backend-third-party-integration/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 79, in execute
return self._execute_with_wrappers(
File "/home/suraj/Desktop/backend-third-party-integration/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 92, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/home/suraj/Desktop/backend-third-party-integration/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 100, in _execute
with self.db.wrap_database_errors:
File "/home/suraj/Desktop/backend-third-party-integration/venv/lib/python3.10/site-packages/django/db/utils.py", line 91, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/suraj/Desktop/backend-third-party-integration/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 105, in _execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: column "product_id" is of type uuid but expression is of type numeric
LINE 1: ...cf23-b45b-4242-a5a2-ae1d756fa81b'::uuid, 2.00, 0, 8461560438...
^
HINT: You will need to rewrite or cast the expression.