Robert Brax
Robert Brax

Reputation: 7318

How to access request.FILES from django admin form submission?

@receiver(pre_save, sender=Document, dispatch_uid='question_save_signal')
def log_save_question(sender, instance, using, **kwargs):
    p = instance  

Here is the code I use to intercept saving in django admin. From inside this function, I would need to access request.FILES to access new files that were just selected in an ImageField and are being submitted. How would you do it ?

Upvotes: 2

Views: 315

Answers (1)

Remi Smirra
Remi Smirra

Reputation: 2539

When you have a pre_save function, the properties are already set to the object, however it is not saved to the db yet. So if your Document Model has an attribute image, you should be able to access it through: instance.image

Upvotes: 1

Related Questions