Jonas Fredriksson
Jonas Fredriksson

Reputation: 355

django css file not loading

I'm struggling to load my custom.css file to use in my bootstrap template:

error:

"GET /static/artdb/css/custom.css HTTP/1.1" 404 1785

path to custom.css:

static/artdb/css/custom.css

base.html:

{% load static %}
       :
<!-- Custom styles for this template --> 
<link rel="stylesheet" href="{% static "artdb/css/custom.css" %}">

urls.py:

urlpatterns = [
    path('artdb/', include('artdb.urls')),
    path('admin/', admin.site.urls),
]+static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

settings.py:

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR,'static')
#STATICFILES_DIRS =(os.path.join(BASE_DIR,"static"),)

any idea what's wrong?

Upvotes: 0

Views: 41

Answers (1)

Pranay reddy
Pranay reddy

Reputation: 160

settings.py:

STATIC_URL = '/static/'
STATIC_ROOT= os.path.join(os.path.dirname(BASE_DIR),'static')
STATICFILES_DIRS= [os.path.join(BASE_DIR,'###path to static folder in project###'),STATIC_URL]

Upvotes: 1

Related Questions