Replies: 7 comments 8 replies
-
yes. many times thought about this! strongly vote for it. this would make many things much more easier! go for it ;) |
Beta Was this translation helpful? Give feedback.
-
yes, that makes sense to me! From a developer's perspective this is easier to handle, using form overrides (those can even be dynamic), especially when it comes to showing different form fields for different file types. Let's do this. |
Beta Was this translation helpful? Give feedback.
-
We currently use django-filer 2.1rc4 for our job portal project which will go live in a few weeks (we use plenty of PNGs) - and I highly appreciate your approach for json for metadata! It would open a whole new way of working with any type of media! |
Beta Was this translation helpful? Give feedback.
-
Doing such change in a backward compatible way might be challenging. I have seen many project overriding the image model (FILER_IMAGE_MODEL). The management pipeline for a File and Image are different as well as their UI and foreignkey widget. I can see how proxymodel for File and Image could be used instead of "polymorphic inheritance" but I can see few challenges along the way. I think that one thing I am missing in the proposal above is Why do you think that this major change is required ? What are the issues you are trying to solve ? |
Beta Was this translation helpful? Give feedback.
-
JsonField is not built in by default on sqlite Does that means we would drop support for |
Beta Was this translation helpful? Give feedback.
-
Some databases don't let you filter on the contents of JSONFields well... but is anyone actually putting any of these subclass model fields in a WHERE clause? I'm sure not; this data is all used after I run the query. |
Beta Was this translation helpful? Give feedback.
-
These model changes sound sensible to me 👍 |
Beta Was this translation helpful? Give feedback.
-
This proposal is the sibling of django-cms/django-cms#7074
Preamble
In django-filer the
File
-model defined as a polymorphic model, so that other Django models can inherit from thereof. The only model, which currently makes use of this is theImage
-model. In addition to the fields required for arbitrary files, it adds the image's width, height, an alt tag, the center of interest (subject_location) and a caption field.While this seems to be a fair set of additional meta-data, images may contain much more information. If one, for instance wants to store the EXIF-headers, or copyright information, he must create his own image model and override it using the special settings variable
FILER_IMAGE_MODEL
. Migrating such a project can be really painful.In addition to this, images can have various formats and an EXIF header may only make sense for JPEG. PNG images use other textual information to store their meta-data. Video and audio files may themself bring their own meta-data, and that also might be of interest without have to open the files for reading.
So, in order to store all that additional information, we would have to create a model for each specific Mime-Type. Since this is not going to happen, I would like make the following proposal to simplify django-filer:
Proposal
I would like to drop the polymorphism from django-filer's
File
-model and also drop django-filer'sImage
model. Instead I would like to add a JSONField to theFile
-model which is used to store all extra context data, such as width, height, copyright information, alt tags, pixel density, EXIF headers, orientation, play-length for video and audio files, etc.This means that the
File
-model will keep all the fields it currently has, plus one JSONField for all the extra data. Adding additional functionality hence becomes much simpler, because we then can inherit from modelFile
as proxy instead of a OneToOne-relation. This prevents us having to deal with foreign keys (causing lot's of database joins) and Django models distributed across different database tables as we do now.I believe that this approach will make it much simpler to add special functionality such as video and audio re-coding or other approaches on how to set the interesting part of an image. It also makes a django-filer's
File
more like a Unix file, where the lower level operating system does not care about the file type. Functionality to read and manipulate those files is handled by an upper layer.Beta Was this translation helpful? Give feedback.
All reactions