I am a newbie in django and I want to upload image in an ImageField
to folder with the name of the title which is retrieved by a CharField
and I get this error on the 8th line while trying to makemigrations
:
AttributeError: 'CharField' object has no attribute 'model'
Here's the code:
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
Anybody knows how to fix it?