13👍
✅
in the “development only” block in your urls.py you need to change
(r'^media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': '/media'}),
to…
(r'^media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),
5👍
ADMIN_MEDIA_PREFIX
is set to \media\
by default, and is probably ‘stealing’ the path. Change that setting, or use a different one for non-admin media – eg site_media
or assets
.
- [Django]-How can I access environment variables directly in a Django template?
- [Django]-How to add new languages into Django? My language "Uyghur" or "Uighur" is not supported in Django
- [Django]-Duplicate column name
2👍
On the dev server, I like to cheat and put the following in my urls.py
if settings.DEBUG:
urlpatterns += patterns('',
(r'^includes/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/path/to/static/files'}),
)
That way anything in the project under the “/includes” folder is server by the dev server. You could just change that to “/media”.
👤Tom
- [Django]-Cross domain at axios
- [Django]-Django: How to format a DateField's date representation?
- [Django]-Is there a way to filter a queryset in the django admin?
1👍
It also worked for me, thanks guys !!
settings.py
MEDIA_ROOT = '/home/pi/ewspaces/ws-classic/xima/media'
MEDIA_URL = '/statics/'
urls.py
if settings.DEBUG:
urlpatterns += patterns('',
(r'^statics/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),
)
inside templates:
<link type="text/css" href="/statics/css/base/jquery.ui.all.css" rel="stylesheet" />
- [Django]-Annotate a queryset with the average date difference? (django)
- [Django]-Copy a database column into another in Django
- [Django]-Django project models.py versus app models.py
0👍
I had a similar problem when I was trying to get jQuery to work. My fix was to add an alias to my Apache httpd.conf file that pointed to the folder containing the .js. You could do the same with your CSS folder.
- [Django]-Add a custom button to a Django application's admin page
- [Django]-Disable session creation in Django
- [Django]-Why does Django's render() function need the "request" argument?
Source:stackexchange.com