Overview

What is blanc-basic-assets?

blanc-basic-assets is a simple Django package to allow image and file uploads to the Django admin.

Assets are a useful place to put files or images which are referenced in other places of a site which can’t justify their own image or file field, such as WYSIWYG content boxes which are used in models.

Assets can also be used as a ForeignKey for models where the same image or file might be used multiple times. Instead of forcing a user to upload the same image each time for the same model, it allows site managers to reuse the same asset through the entire site.

Design notes

Compared to typical Django file and image upload fields, there are two main differences which users should be aware of.

Deleted assets deletes the file

If you delete the model for an image or file asset, the file which has been uploaded will be deleted as well. Django usually keeps uploaded files by default, however to keep the site clean of cruft any deleted file or image objects will be deleted from the filesystem.

New uploads of a file deletes the old file

Django usually keeps the original version of the file intact, and any file uploads with the same name will be changed, so future uploads of example.txt will be example-1.txt, example-2.txt, etc.

To try and keep the original filename, the old file associated with an asset will be deleted - allowing the new version of a file to keep the same name. This is useful when you want to upload a new version of a file referenced from a link in a WYSIWYG.