-3

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

Ali Umer
  • 13
  • 5
  • Did you add the static urls to your urlpatterns? check [Serving static files during development](https://docs.djangoproject.com/en/3.1/howto/static-files/#serving-static-files-during-development) in the documentation – Abdul Aziz Barkat Mar 01 '21 at 12:49
  • I tried it. still same nothing shows up – Ali Umer Mar 01 '21 at 12:57
  • Please replace pictures of code with code in text, describe folder structure as text. Please specify what error message / http status you get when trying to access those URLs. – Ivan Starostin Mar 01 '21 at 12:57
  • https://stackoverflow.com/help/how-to-ask – Ivan Starostin Mar 01 '21 at 12:58
  • So, no 404 errors (map file is not required)? Try fixing this then `main.js:2 Uncaught TypeError: Cannot set property 'innerHTML' of null at main.js:2` – Ivan Starostin Mar 01 '21 at 14:13

2 Answers2

0

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

Henrik
  • 828
  • 8
  • 34
0

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.

Ali Umer
  • 13
  • 5