[Answered ]-Django – Multiple Image Upload

2👍

It doesn’t complicate the admin screen at all thanks to the addition of inline model admin objects. You would have the property admin page with a list of images below it, with the inline giving you the ability to associate new images with each property.

This is pretty much the classic example of a foreign key scenario. I’d question the use of a many to many relationship in that a photo of a property shouldn’t be being linked against other properties (though I suppose in the case of blocks of flats…)
You need to store the association between property and image and that is done via a foreign key relationship if you want your database to be in any way well designed. Otherwise you’ll be having to kludge many file names into a single field which is very messy and almost unqueryable in any sane way.

Alternatively if the admin doesn’t give you enough in the way of flexibility it wouldn’t be too hard to construct a ModelForm that allowed associating any number of images to upload.

👤Chris

Leave a comment