django-filer

3.4.4 · active · verified Thu Apr 16

django-filer is an active file management application for Django that simplifies handling of files and images within Django projects. It provides a robust file browser and model fields for seamless integration. The current version is 3.4.4, and the library maintains an active release cadence with frequent updates and patches.

Common errors

Warnings

Install

Imports

Quickstart

To get started with django-filer, install the package, add `filer`, `easy_thumbnails`, `mptt`, and `polymorphic` (if not already present) to your `INSTALLED_APPS` in `settings.py`, and define `MEDIA_ROOT` and `MEDIA_URL`. Then, run migrations. You can then use `FilerImageField` or `FilerFileField` in your Django models, similar to Django's native `ImageField` and `FileField`. Remember to specify an `on_delete` parameter for these fields.

# settings.py
INSTALLED_APPS = [
    # ... other apps
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'mptt', # Required by easy_thumbnails/polymorphic if not Django-Filer 3.0+
    'easy_thumbnails',
    'filer',
    'polymorphic',
]

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

# models.py
from django.db import models
from filer.fields.image import FilerImageField
from filer.fields.file import FilerFileField

class Product(models.Model):
    name = models.CharField(max_length=255)
    image = FilerImageField(null=True, blank=True, on_delete=models.SET_NULL, related_name="product_images")
    brochure = FilerFileField(null=True, blank=True, on_delete=models.SET_NULL, related_name="product_brochures")

    def __str__(self):
        return self.name

view raw JSON →