Reputation: 1591
I have a following model for my files:
class Import(models.Model):
file = models.FileField(upload_to='%Y/%m/%d')
And I save them like this:
f = request.FILES['import']
if f.size < settings.MAX_UPLOAD_SIZE:
x = Import.objects.create(file=f)
My media root:
MEDIA_ROOT = os.path.join('/home/xyz/project/main', 'upload/')
The problem is, when I inspect my x object like:
print x.file.path
it will return "/home/my-computer-name/..." instead of "/home/xyz/...". What am I doing wrong? Django 1.8, Ubuntu. The file has been uploaded to correct path.
Upvotes: 1
Views: 514