Open roaddust2 opened 1 year ago
Hello @roaddust2
I am not aware of this syntax for declaring STATICFILES_DIRS
settings as tuples:
STATICFILES_DIRS = (
("css", os.path.join(STATIC_ROOT, 'css/')),
("images", os.path.join(STATIC_ROOT, 'images/')),
("js", os.path.join(STATIC_ROOT, 'js/'))
)
Shouldn't it be this:
STATICFILES_DIRS = [
os.path.join(STATIC_ROOT, 'css/'),
os.path.join(STATIC_ROOT, 'images/'),
os.path.join(STATIC_ROOT, 'js/')
]
?
Thank you for the answer! Docs says Django allow you to declare STATICFILES_DIRS with prefixes as a tuples:
https://docs.djangoproject.com/en/4.2/ref/settings/#prefixes-optional
Well, I added media folder to static dirs, and now images are loading. But unfortunately they still .jpg 😅
STATICFILES_DIRS = [
("css", os.path.join(STATIC_ROOT, 'css/')),
("images", os.path.join(STATIC_ROOT, 'images/')),
("js", os.path.join(STATIC_ROOT, 'js/')),
("media", 'media/'),
]
P.S. But it is a bad practice to put media in static anyway
I have a problem serving media files with webp tag. Just followed steps in documentation. Maybe I am missing something?
My settings:
Template example:
Output error:
So "/static/" is added to the path, when correct path is /media/images/categories/img.jpg. With static tag media serving correctly and everything is fine