Reputation: 377
i have a list of images for a every object, but can not use it.
models:
from django.contrib.postgres.fields import ArrayField
class MyModel(models.Model):
national_card = ArrayField(
models.ImageField(upload_to=directory_path), blank=True, null=True,
)
serializer:
class MyModelSerializer(serializer.ModelSerializer):
class Meta:
model = MyModel
fields = '__all__'
database (column of national_card):
{
orders/2d4ba9ff-44af-44e9-9203-a0aad5a3c7ec/380cbbf0-1b73-4e36-996d-015c81dbaa71.jpg,
orders/2d4ba9ff-44af-44e9-9203-a0aad5a3c7ec/380cbbf0-1b73-4e36-996d-015c81dbaa71.jpg
}
result of serializer:
{
"national_card": [
null, null
]
}
Upvotes: 1
Views: 1128
Reputation: 377
ArrayField
and FileField
(ImageField
, ...) is not compatible. and not work correctly. (can not copy file to upload_to
)
https://code.djangoproject.com/ticket/25756
but,
{
"national_card": [
null, null
]
}
This output has no connection to it! But because of multiple inheritance. and one of them bad effect to it.
Upvotes: 2