I'm trying to change my model.
For now, I use other model to save images for my posts.
I think most people use like this.
However, I heard django supports ArrayField if database is postgresql.
import django.contrib.postgres.fields import ArrayField
so, I trying to change my model. such as
class post(models.Model):
title = ...
content = ...
images = ArrayField(base_field=models.ImageField(...))
What I want to know is How can I create these base_field's data in view? we can access normally if model is
class tmp(models.Model):
img = models.ImageField()
in view, or wherever, we just do like
img = request.FILES['data']
tmp.save()
this.
However, In ArrayField, I want to do is
tmp_imgs = TemporaryImagesTable.objects.filter(user=user)
for tmp_img in tmp_imgs:
images.append(???????????????) (append or images = ?????)
I want to do is
images.append(new ImageField(tmp_img))
like this!
please help me,