I have a django project in which from the admin I can upload photos one at a time, now, I want to upload more than one for the same element (database registration) and I would like to know what is the way less traumatic and easy, since it is usually just add enctype="multipart / form-data" but in django everything is very far fetched.
I have found django-admin-multiupload but I find it somewhat complex for the simple thing I need, it is not an external form but to make the simple ImageField field allow multiple files , you have to do some way of configuring that, right?
models.py
class Photo(models.Model):
pho_code = models.AutoField(db_column='PHO_code', primary_key=True)
pho_url = models.ImageField(db_column='PHO_url', upload_to='media/documents/%Y/%m/%d')
poi = models.ForeignKey(Poi, models.DO_NOTHING, db_column='POI_code')
class Meta:
managed = False
db_table = 'PHOTO'
def __unicode__(self):
return str(self.pho_url)
admin.py
class PhotoAdmin(admin.ModelAdmin):
list_display = ['pho_code', 'pho_url', 'poi']
form = PhotoForm
class Meta:
model = Photo