nat
nat

Reputation: 1591

wrong file path when uploading a file in django

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

Answers (1)

nat
nat

Reputation: 1591

ok, forget it. I just put wrong settings file when printing the path

Upvotes: 1

Related Questions