Django Adding Static Path To Current Url
I have my static files in a folder assets in the application directory. When I go to the main page (/), the static files are being loaded perfectly fine from /assets/. If I go to /
Solution 1:
You should change the HTML tag in your template from
<link href="assets/plugins/uniform/css/uniform.default.css"
rel="stylesheet"type="text/css"/>
to
<link href="/assets/plugins/uniform/css/uniform.default.css"
rel="stylesheet"type="text/css"/>
Please note the slash /
in front of the relative URL. Without it, the browser will assume that assets
directory is a subdirectory of the current one. With it, it will always start from the root directory.
Baca Juga
- Not Going Through The Django View Through Ajax Post Data
- My Link To Manifest.json In Index.html Works When I Run React Script 'yarn Start', But Not When I Run 'python3 Manage.py Runserver'
- 'python Manage.py Collectstatic' Is Still Collecting Static To C Drive Instead Of S3 Bucket, Am I Missing Something?
Post a Comment for "Django Adding Static Path To Current Url"