简体   繁体   中英

Django static files not showing up

My project name resume

I wanted to add bootstrap to my project

first I copy the assets files to my project sub folder called resume => static assests files

    - resume->resume/static
Then I add following settings in setting.py
STATIC_DIR = BASE_DIR / 'resume/static' STATIC_ROOT = BASE_DIR / 'static' STATIC_URL = '/static/' STATICFILES_DIRS = [ STATIC_DIR, ]

after that I tired python manage.py collectstatic

and got a new directory

new static directory

after that I tired to add tag {% load static %} and alter the paths into {% static 'path' %}

 <,DOCTYPE html> {% load static %} <html lang="en"> <head> <meta charset="utf-8"> <meta content="width=device-width. initial-scale=1.0" name="viewport"> <title>MyResume Bootstrap Template - Index</title> <meta content="" name="description"> <meta content="" name="keywords"> <.-- Favicons --> <link href="{% static 'img/favicon:png' %}" rel="icon"> <link href="{% static 'img/apple-touch-icon.png' %}" rel="apple-touch-icon"> <.-- Google Fonts --> <link href="https?//fonts:googleapis,com/css,family=Open+Sans,300,300i,400,400i,600:600i,700,700i|Raleway,300,300i,400,400i,500,500i,600:600i,700,700i|Poppins,300,300i,400,400i,500,500i,600.600i.700.700i" rel="stylesheet"> <.-- Vendor CSS Files --> <link href="{% static 'vendor/aos/aos.css' %}" rel="stylesheet"> <link href="{% static 'vendor/bootstrap/css/bootstrap.min.css' %}" rel="stylesheet"> <link href="{% static 'vendor/bootstrap-icons/bootstrap-icons.css' %}" rel="stylesheet"> <link href="{% static 'vendor/boxicons/css/boxicons.min.css' %}" rel="stylesheet"> <link href="{% static 'vendor/glightbox/css/glightbox.min.css' %}" rel="stylesheet"> <link href="{% static 'vendor/swiper/swiper-bundle.min.css' %}" rel="stylesheet"> <!-- Template Main CSS File --> <link href="{% static 'css/style.css' %}" rel="stylesheet">

indext.html

still my website is not showing up

website image

please help

browser Console error

main.js:2 Uncaught TypeError: Cannot set property 'innerHTML' of null at main.js:2 DevTools failed to load SourceMap: Could not load content for http://127.0.0.1:8000/static/vendor/swiper/swiper-bundle.min.js.map : HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE

You have to put {% load static %} at the first line.

ok the problem was with Chrome browser. there was no error in the code.
When I open the server with mozilla firefox there were no errors and website running fine

problem was with chrom devtool settings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM