How can I use static img file in windows's django
I'm trying to make django webapplication. It worked on linux and wsl.But now I need to make windows native development environment.
However when I try to get the static img file I get following errors.
django.core.exceptions.SuspiciousFileOperation: The joined path (C:\tcgcreator\img\devirun.png) is located outside of the base path component (C:\Users\jidpn\tcgcreator_eternal_beta\tcgcreator\static)
My settings.py is below(something related to static)
DEBUG = True
STATIC_URL = 'static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static")
urls
]+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
This is something I put in the img tag
<img class="img_card" src="/static//tcgcreator/img/devirun.png">
My django version is 4.2.3 and python version is 3.11.4
I looked at Django Suspicious Operation and tried the same thing. But it didn't work for me
I'm hoping to find answer to this problem
The path to the static image file you are providing in your template img src
here is not correct.
<img class="img_card" src="/static//tcgcreator/img/devirun.png">
Django immediately recognizes this as a SuspiciousFileOperation.
To rightly specify the static file Django serves for you, see How to manage static files (e.g. images, JavaScript, CSS.)
One more thing, consider deleting your __pycache__
folder since you are moving from WSL back to full Windows.