I have problems with extending Django's filer, probably because my knowledge of Django is not sufficient yet.
Basically, what I would like to achieve is to extend Django filer image model to be able to add a category
to images. Could someone help me with this topic?
Code example is from:
http://django-filer.readthedocs.io/en/latest/extending_filer.html#providing-custom-image-model
My code (all in myPlugins
app):
models.py:
from filer.models.abstract.BaseImage
class CustomImage(BaseImage):
category = models.CharField(max_length=20, blank=True, null=True,)
class Meta:
app_label = 'myPlugins'
admin.py:
from django.contrib import admin
from filer.admin.imageadmin import ImageAdmin
from filer.models.imagemodels import Image
class CustomImageAdmin(ImageAdmin):
pass
CustomImageAdmin.fieldsets = CustomImageAdmin.build_fieldsets(
extra_main_fields=('default_alt_text', 'default_caption', 'category'),
extra_fieldsets=(
('Subject Location', {
'fields': ('subject_location',),
'classes': ('collapse',),
}),
)
)
admin.site.unregister(ImageAdmin)
admin.site.register(Image, CustomImageAdmin)
In settings.py, I've added:
FILER_IMAGE_MODEL = 'myPlugins.models.CustomImage'
I'm getting an error:
ValueError: Cannot create form field for 'image' yet, because its related model 'myPlugins.models.CustomImage' has not been loaded yet