Django – Admin based File Management

Django's admin panel can be enhanced with django-filer to provide comprehensive file management capabilities. This allows administrators to upload, organize, and manage various file types directly from the admin interface.

Installing Django-Filer

First, install the required package using pip ?

pip install django-filer

Configuration

Add the necessary apps and configuration to your settings.py file ?

INSTALLED_APPS = [
    ...
    'easy_thumbnails',
    'filer',
    'mptt',
    ...
]

THUMBNAIL_HIGH_RESOLUTION = True

THUMBNAIL_PROCESSORS = (
    'easy_thumbnails.processors.colorspace',
    'easy_thumbnails.processors.autocrop',
    # 'easy_thumbnails.processors.scale_and_crop',
    'filer.thumbnail_processors.scale_and_crop_with_subject_location',
    'easy_thumbnails.processors.filters',
)

The configuration includes easy_thumbnails for image processing, filer for file management, and mptt for hierarchical folder structure. The thumbnail processors enable automatic image resizing and cropping.

URL Configuration

Add the filer URLs to your main urls.py file to enable file access ?

from django.urls import path, include

urlpatterns = [
    ...
    path('filer/', include('filer.urls')),
    ...
]

This creates a dedicated URL pattern where all uploaded files will be accessible through canonical URLs.

Database Migration

Run migrations to create the necessary database tables ?

python manage.py makemigrations
python manage.py migrate

Admin Interface Features

Once configured, the Django admin will display a "Filer" section with the following capabilities:

  • File Upload: Upload various file types including images, documents, and media files
  • Folder Management: Create hierarchical folder structures to organize files
  • File Details: View file metadata, dimensions, and file size
  • Canonical URLs: Generate permanent URLs for files that can be used in templates
  • Thumbnail Generation: Automatic thumbnail creation for images

Usage in Templates

You can reference uploaded files in your Django templates using the canonical URL ?

# In your template
<img src="{{ file.canonical_url }}" alt="{{ file.name }}">

# Or using the filer template tags
{% load filer_image_tags %}
{% filer_image file 300x200 %}

Conclusion

Django-filer provides a powerful file management system for the admin panel, enabling organized file storage with folder structures and automatic thumbnail generation. The canonical URL feature ensures files remain accessible with permanent links for use throughout your application.

Updated on: 2026-03-26T00:36:35+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements