I have a project where I use a database to upload an image as well as some other info but when I am in django admin I click the choose file button which allows you to select an image but nothing happens. This is my image row
image = models.ImageField(upload_to='portfolio/images/')
After you select the image to be uploaded, you still need to save the data in the admin.
Also, what does the complete model look like?
What does your ModelAdmin class look like?
guyrozo
February 4, 2022, 11:59pm
3
The thing is the I can edit the other properties just not the image one. Here is my complete model. It is it’s own separate class.
class Project(models.Model):
title = models.CharField(max_length=100)
description = models.CharField(max_length=250)
tools = models.CharField(max_length=200, default="Some String")
#image uploaded to media/portfolio/images
image = models.ImageField(upload_to='portfolio/images/')
url = models.URLField(blank=True)
def _str_(self):
return self.title
Is this a development environment or a production deployment?
What is your MEDIA_ROOT setting?
It’s a production deployment, DEBUG is false and my my MEDIA_ROOT is
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
I deleted my static files directory and reinstalled some python modules and it seems I can add images now.
guyrozo
February 10, 2022, 9:22pm
7
I fixed the issue with amazon s3.
How did you fix this? I’m having exactly the same issue