[Django]-Django not found static files in the subfolder of static

2πŸ‘

βœ…

Now that you switch the static file folder to '/static/myapp/'

You should use <img src="/static/images/my.png" /> in your tag.

Generally, you should use {% static %} template tag to do this, like below (assume STATIC='/static/').

{% load staticfiles %}

<img src="{% static 'myapp/images/my.png' %}" />

to learn more, see the tutorial, https://docs.djangoproject.com/en/1.6/intro/tutorial06/

I suggest you to read all the tutorial (part1 – part6) in https://docs.djangoproject.com/en/1.6/

So that you can know deep enough for the basis.

πŸ‘€Alfred Huang

1πŸ‘

You can found some help in these answers also

  1. static files problem
  2. STATIC_URL Not Working

In my configuration I have a directory structure where static files are inside my app like this

djangoprj
    djangoprj
        settings.py
        urls.py
        wsgi.py
        __init__.py
    apps
        myapp
            ...
            templates
                *.html
            static   
                myapp
                   mystaticfiles
            ...
            ...

In settings

INSTALLED_APPS = (
    ...
    'django.contrib.staticfiles',
    ...
)

STATIC_URL = '/static/'

and in templates I use β€˜static’ tags

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

I hope this can help you

Leave a comment