'How to save ProductAttributesValues in Django Oscar Commerce
I'm trying to save m2m relation in Product model on Django Oscar Commerce package, the model has an many to many relation through the ProductAttributeValues model.
Making Postan POST method query to url 127.0.0.1:8000/api/products/1/update/
serializers.py:
class ProductAttributeValueSerializer(OscarModelSerializer):
class Meta:
model = ProductAttributeValue
fields = '__all__'
class ProductSerializer(OscarModelSerializer):
attribute_valuess = ProductAttributeValueSerializer(many=True, read_only=False)
class Meta:
model = catalogue_models.Product
fields = '__all__'
The json content:
{
'title': 'Producto 4',
'is_public': True,
'description': 'descripción',
'attribute_values': [
{'value_text': 'contenido', 'attribute': 1, 'product': 1},
{'value_text': 'contenido', 'attribute': 2, 'product': 1}
]
}
The postman return this json:
{
"attribute_values": [
{
"non_field_errors": [
"The fields attribute, product must make a unique set."
]
},
{
"non_field_errors": [
"The fields attribute, product must make a unique set."
]
}
]
}
Anybody could help me please ? Thanks in advance.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
