#25756: ArrayField does not work with FileField
----------------------------------+------------------------------------
Reporter: Anthony Dong | Owner: (none)
Type: Bug | Status: new
Component: contrib.postgres | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------
Comment (by johnthagen):
Bug still exists in 2.2.10. This transitively affects users of Django REST
Framework who try to serialize multiple Base64 files into a ListField:
{{{
# models.py
from django.contrib.postgres.fields import ArrayField
class Store(Model):
files = ArrayField(models.FileField(upload_to='files', null=True,
blank=True))
}}}
{{{
# serializers.py
from drf_extra_fields.fields import Base64ImageField
from rest_framework.fields import ListField
class StoreSerializer(ModelSerializer):
datasheets = ListField(child=Base64ImageField())
class Meta:
model = Store
fields = '__all__'
}}}
{{{
# views.py
class StoreViewSet(ModelViewSet):
queryset = Store.objects.all()
serializer_class = StoreSerializer
}}}
Doing this results in incorrect results, returning `null` instead of a
file path and failing to save the file. Would be really nice if it was
possible to fix this.
--
Ticket URL: <https://code.djangoproject.com/ticket/25756#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/064.1c3a0be1c39877c60b6c3bcfb4b336da%40djangoproject.com.