<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=338168267432629&amp;ev=PageView&amp;noscript=1">
Programming

django-filebrowser and grapelli

Django-grappelli provides a revamp of the existing Django admin look and feel. In itself, it simply makes your site look better—you’ll need this in case a site also needs to provide admin access to the product owner. For this case, however, we’re using Grappelli as a dependency for django-filebrowser. Django-filebrowser …


Django-grappelli provides a revamp of the existing Django admin look and feel. In itself, it simply makes your site look better—you’ll need this in case a site also needs to provide admin access to the product owner. For this case, however, we’re using Grappelli as a dependency for django-filebrowser.
Django-filebrowser does exactly what its name says. In a nutshell, django-filebrowser lets you navigate through and manipulate your media files through your Django admin site. This is useful should you eventually need the end-user to be able to control image files without having to dig deep into the server’s internal filesystem.
First, make sure the dependencies are installed. PIL may prove tricky to install, but from there it’s all simple.

  • pip install django==1.2
  • pip install PIL==1.1.7
  • pip install django-grappelli=2.1
  • pip install django-filebrowser==3.1

You’ll be able to follow these steps, except for the ‘collectstatic’ management command (since we’re using Django 1.2) Also, I used these additional settings:

import os
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
ADMIN_MEDIA_PREFIX = '/admin-media'STATIC_DOC_ROOT = PROJECT_ROOT+ '/media'

Note: the PROJECT_ROOT style makes your settings more portable, so it’s a good habit to start.
Next, we make a symbolic link to the grappelli media folder (in site-packages) from your project media folder.(In the directory defined by MEDIA_ROOT)ln —symbolic /PATH/TO/site_packages/grappelli/media grappelli
Then, make sure your installed apps has this order:

INSTALLED_APPS = ('grappelli','filebrowser','django.contrib.admin',)

Same goes for your urls,

urlpatterns = patterns('',(r'^admin/filebrowser/', include('filebrowser.urls')),    
(r'^admin/', include(admin.site.urls)),(r'^grappelli/', include('grappelli.urls')),
(r'^media/(?P.*)$', 'django.views.static.serve', {'document_root': '/home/kevinzana/Desktop/FileBrowserTest/filebrowser_test/media'}),)

(In the directory defined by MEDIA_ROOT)

ln --symbolic /PATH/TO/site_packages/filebrowser/media filebrowser

Indicate in additional settings using this as reference:http://code.google.com/p/django-filebrowser/wiki/Settings

python manage.py runserver --adminmedia= 'project_root'/media/grappelli

Once you’re set up, check it out with the following url:/admin/filebrowser/browse/

Similar posts

Get notified about the latest in Tech

Be the first to know about new tech from the experts at Bixly!