I have the following model field
logo = models.ImageField(upload_to=municipality_logo_file_name)
and function that uploads the image to the desired location.
def municipality_logo_file_name(instance, filename):
name, extension = os.path.splitext(filename)
return os.path.join('municipality', 'logo', str(uuid.uuid4()) + extension.lower())
In the development mode, a file uploads correctly to for example /media/municipality/logo/1e3cc24a-841b-4577-aa59-b53e5b10420b.png and then displays correctly in the template using
<img src="{{ municipality.logo.url }}" alt="Logo obce" style="max-height: 8rem; width: auto">
In the production, file uploads well, but does not display in the template and the url cannot be followed to display image, the response is
Not Found
The requested resource was not found on this server.
Using IIS and wfastcgi.py.
Any hint as to why this might be happening would be much appreciated.