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
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
π€Salvatore Avanzo
- [Django]-Can Python Generators be used in Django Views?
- [Django]-Django β ModelAdmin media definition
- [Django]-Writing multiple page pdf from html template using weasy print and django
- [Django]-Bootstrap modal not updating modal content
- [Django]-How to unregister table from django admin whose created when package are installed
Source:stackexchange.com