Django is showing me a 404 error instead of my image

my friends, this is my first question here. So, I follow the Django documentation and some questions here, but the problem keep happening. I did what was said on other similar questions, like this one, for examaple: But the problem persists.

So, my model looks like this:

class UserProfile(models.Model):
    user = models.OneToOneField(User, on_delete = models.CASCADE, primary_key=True)
    picture = models.ImageField(blank = True, null = True, upload_to = user_directory_path)
    whatsapp = models.PositiveIntegerField(blank = True, null = True)

My settings looks like this:

MEDIA_ROOT = f"{BASE_DIR}/media"
MEDIA_URL = '/media/'

I added

+ static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT)

to the end of my urls.py file.

The folder and images are being created on my file system when I add them via the admin, but when I click to see them over there I recieve a 404.

I am making a mobile app and serving my data using Django Rest Framework, the images are the only thing giving me a headache right now.

Hmmm… :thinking: (How use FileField model with ReportBro with Django?)

Anyway, you have:

What is “user_directory_path”?

What is the real directory in which the file is stored?

What is the URL that was rendered in the html?

What does your template look like for referencing that image?

In my situation, however, I have to read the file, preserve it in memory, and then send the image -
5dceab7ed511ef0001c7f139-198x149-1x

immediately to the report because using this image requires a lengthy process.