Sunday, February 27, 2011

Installing Grappelli

One very cool app for Django is the filebrowser app, which lets you peruse your MEDIA_URL folder, rename files, and view different thumbnail versions of your image. A screenshot of the console is here:


One thing you also notice is that the filebrowser app uses a different look and feel for Django. In fact, it depends on the grappelli Django app to install, which is a re-skinned version of the Django admin console. It definitely gives it a much more slick view than the one that comes with the normal Django install.
pip install django-grappelli
pip install django-filebrowser

The installation for grappelli is located here:
http://django-grappelli.readthedocs.org/en/latest/quickstart.html#installation

One thing to note is that the install instructions refer to using the collectstatic management command, which relies on the django.contrib.staticfiles library in the Django 1.3 development version. If you're running Django v1.2, you'll find that django.contrib.staticfiles just doesn't exist. The documentation for this module is located at:
http://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/

For now, you can skip installing Django v1.3 and not use the collectstatic management command. If you do, then you

You do need to modify your settings.py file to define the ADMIN_MEDIA_PREFIX...the documentation says to use STATIC_URL but unless you're using Django v1.3 and/or the collectstatic command, then you're probably better off copying the grapelli/template files into a separate dir within your MEDIA_URL dir:
ADMIN_MEDIA_PREFIX = MEDIA_URL + "grappelli/"

You'll want to verify that you can render/view correctly the grappelli template files you copied. If you're running a debug server, you may get "Permission Denied" messages when trying to access the grappelli dir. The solution appears to be set ADMIN_MEDIA_PREFIX to a fully qualified hostname:

http://stackoverflow.com/questions/1081596/django-serving-admin-media-files

Another way is to use the --adminmedia flag, which seems to be a point of contention on the Django forums:

http://code.djangoproject.com/ticket/8336
./manage.py runserver --adminmedia=`pwd`/media/grappelli
http://code.google.com/p/django-grappelli/issues/detail?id=149

Keep in mind that if you've modified any of the admin/templates from the original Django source, the admin/templates that grappelli are nothing like the vanilla install, which means you'll have to re-copy those files and re-implement any custom code you have.

No comments:

Post a Comment