Ross
Ross

Reputation: 2417

Django, CSS is loading, however images and js return a 404

I am creating a Django website and have created a login pages for the website. When I run this on the development server the CSS for the page loads but the images and JavaScript are returning a 404 error. but they are in the same assets folder.

enter image description here

Folder Structure:

enter image description here

settings.py:

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

Login.html:

<div class="h-center">
    <img class="logo" src="{% static 'assets/base/img/logo/logo.jpg' %}">
</div>

I don't understand why it is only loading the CSS files.

Upvotes: 1

Views: 88

Answers (1)

babak gholamirad
babak gholamirad

Reputation: 568

comment the STATIC_ROOT like this:

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

STATIC_ROOT is for command "collectstatic"

Upvotes: 1

Related Questions