1

I'm using django admin site (v1.9.6) and recently installed file-browser for managing images and documents. I followed installation steps and file-browser is shown in admin interface but I cant upload images and documents. When trying to access them 404 errors shows up (also thumbnails are not shown in file-browser page):

Page not found (404)
     Request Method:    GET
     Request URL: http://127.0.0.1:8000/media/uploads/aaaaaaaaaaalula.png

But the file is there, if I make

ls media/uploads/aaaaaaaaaaalula.png

it shows the file, so it's uploaded.

my settings.py:

MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_URL = '/media/'
ADMIN_MEDIA_PREFIX = '/media/admin/'

and url.py

from django.conf.urls import patterns, include, url
from django.contrib import admin
from filebrowser.sites import site


urlpatterns = [
    url(r'^admin/filebrowser', include(site.urls)),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^$', include(admin.site.urls)),
]

Thanks in advance for help.

C.

3 Answers 3

2

Ok, here is the solution:

https://docs.djangoproject.com/en/1.9/howto/static-files/#serving-static-files-during-development

The issue was that I was testing django-filebrowser with development server

Sign up to request clarification or add additional context in comments.

Comments

0

You are not putting url for displaying image. In setting.py-

MEDIA_ROOT = os.path.join(BASE_DIR, "media/") 
MEDIA_URL = '/media/' 
In URLs.py--
Url(r'^media/(?^<path>.*)$','django.views.static.serve',{'document_root':
 settings.MEDIA_ROOT,}),

I think it can help you

Comments

0

You can do:

from django.conf.urls.static import static
from django.conf import settings

urlpatterns = [
    #your urls
]

if settings.DEBUG: # will be 'True' in development
    urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.