2

I'm learning Django 2.0
I have a ready-made template, that contains all assets in assets folder.
All references in template starts from assets/..., and I'm gonna keep it: all links should looks like {% static 'assets/...' %}
My Django app has following structure:

myapp
├───manage.py
└───mysite
    └───static/mysite/static/assets # some mess here?
    └───templates/mysite/index.html

Inside index.html I'm using {% load static %},
In settings I have just

STATIC_URL = '/static/'

but framework can't find path to assets. What I'm doing wrong?


UPD

{% load static %}
<link rel="stylesheet" type="text/css" href="{% static 'assets/css/bootstrap.min.css' %}">
sgauri
  • 694
  • 8
  • 18
shmnff
  • 647
  • 2
  • 15
  • 31

2 Answers2

1

If you want to use static file like.

CSS

JavaScript

Images

On Templates Use

{℅ load staticfiles %}

Community
  • 1
  • 1
1
 └───static/mysite/static/assets  - You should to change this,**like bellow**

myapp
└───Assets
├───manage.py
└───mysite
    └───mysite # your project files
    └───templates/index.html

and also : in your setting.py like this :

    STATIC_URL = '/static/'
    STATICFILES_DIRS = [
        os.path.join(BASE_DIR, 'assets'),
    ]

and also : you need to change setting.py file 'DIRS': ['templates'], or 'DIRS': ['myapp/templates']

Rajan
  • 1,512
  • 2
  • 14
  • 18
Alireza Atashnejad
  • 612
  • 1
  • 6
  • 22