Skip to content
Advertisement

Cannot access staticfiles using Pycharm Community Edition

UPDATE: I have updated the followin This is the html file for that specific webpage.

<!-- load the path to your static file-->
{% load static %}

<link rel="stylesheet" type="text/css" href="{% static 'music/style.css'%}"/>

{% if all_albums %}
    <h3>Here are all my albums:</h3>
    <ul>
        {% for album in all_albums %}
            <li><a href="{% url 'music:detail' album.id %}">{{ album.album_title }}</a></li>
        {% endfor %}
    </ul>
{% else %}
    <h3>You don't have any albums</h3>
{% endif %}

Here is the CSS file:

body{
    backgroud : white url("images/background.jpg");
}

I have also changed the settings file like this:

import os

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

You can see my project tree as under for more clarification:

Project Tree

Now there is no error but the background image that I am trying to get is now shown on that webpage:

Please help me out! Is this because of COMMUNITY EDITION?

Advertisement

Answer

to load the static content from the CSS file, you have to use full static URL like

body{
    backgroud : white url("/static/images/background.jpg");
}
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement