我是django的新手,我想将ImageField
上的图片上传到CharField
检索到的标题名称的文件夹中,我在第8行收到此错误试图makemigrations
:
AttributeError:' CharField'对象没有属性' model'
以下是代码:
from django.db import models
from django.contrib.postgres.fields import ArrayField
class Starter(models.Model):
title = models.CharField(max_length=200)
price = models.IntegerField()
description = models.TextField()
image = ArrayField(models.ImageField(upload_to='starter/{}'.format(title)), size=10)
class Meta:
ordering = ('title', 'price',)
def __str__(self):
return self.title
有人知道如何解决它吗?