1👍
✅
What version of django are you using?
in 1.4 you can do this in your template:
<img src="{{ STATIC_URL }}hi.jpg" />
or
<img src="../static/hi.jpg" />
and in your settings.py:
MEDIA_ROOT = '/Users/YOURUSERNAME/Desktop/YOURPROJECTNAME/static'
^^^ this just has to be the path to the static directory in your project ^^^
MEDIA_URL = '/static/'
STATIC_ROOT = ''
STATIC_URL = '/media/'
then in your urls.py:
if settings.DEBUG: urlpatterns += patterns('', (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), )
- [Answer]-Using jinja2 macro from filter using jingo
- [Answer]-Dojo doesn't see custom widget
- [Answer]-Optimal way to filter object from list of django model objects
- [Answer]-Update parent values in Django admin
Source:stackexchange.com