Opened 10 years ago

Closed 10 years ago

#10948 closed (duplicate)

pre_save used on FileField/ImageField doesn't work

Reported by: Lior Gradstein Owned by: nobody
Component: File uploads/storage Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


If I set a signal that intercepts as pre_save and try to access a FileField/ImageField's path, I don't get the same result. It seems the 'upload_to' attribute is not taken into account!

Here's a very simple example to show the problem:

  • (relevant parts only):

MEDIA_ROOT = '/tmp/static'
MEDIA_URL = '/static/'


from django.db import models
from django.db.models import signals

class MyModel(models.Model):

myfile = models.FileField(upload_to="uploads")

def intercept(sender, instance, signal, *args, kwargs):

print instance.myfile
print instance.myfile.path
print instance.myfile.url

signals.pre_save.connect(intercept, sender=MyModel)

  • In Django 1.0.2-final:


  • In Django 1.1+ (1.1beta and latest SVN version 1.1 beta 1



Please the associated thread on

Change History (1)

comment:1 Changed 10 years ago by Karen Tracey

Resolution: duplicate
Status: newclosed

I did create a ticket for this a while ago: #10788. Apologies for not noting that in the dev discussion thread.

Note: See TracTickets for help on using tickets.
Back to Top