views:

251

answers:

2

I'm doing some local development using Django and Satchmo. When I upload product images locally via the admin, the path to the image shows up as an absolute path, complete with drive letter, rather than the proper relative path.

Stranger still, Satchmo saves both the original image and the thumbnails it generates in both me /media/ directory and /media/images/ directory, the latter being where I want them to go.

The relavent settings are as follows:

# path relative to the settings.py file
DIRNAME = os.path.abspath(os.path.dirname(__file__).decode('utf-8'))

MEDIA_ROOT = os.path.join(DIRNAME, 'media')
MEDIA_URL = 'http://localhost:8000/'
ADMIN_MEDIA_PREFIX = '/media/'

I have tripple checked the local_settings.py file and there is no mention of the word 'media' anywhere in it, so I'm sure there are no setting overrides.

If it helps, I'm on Windows, but I'm using all the proper unix notation for my paths.

+1  A: 

This is a Windows only bug. I am developing a Satchmo app on Windows and it does this, but when I deploy on a Linux box it works just fine. I just go into the database and edit the paths there when I am doing testing on my Windows box.

Jason Christa
+1  A: 

Turns out the issue is a problem with slash directions in the settings.py file.

Usually, I create a relative_path() function in my settings.py file so I can easily set:

MEDIA_ROOT = absolute_path('media')

The version of Satchmo I was using encouraged the use of a DIRNAME setting instead:

DIRNAME = os.path.abspath(os.path.dirname(__file__).decode('utf-8')

The issue was, using this technique, my MEDIA_ROOT was being set as such:

MEDIA_ROOT = os.path.join(DIRNAME, 'media')

But this was using the Windows backslashes instead of the Unix forward slashes. I've resolve it with:

MEDIA_ROOT = os.path.join(DIRNAME, 'media').replace('\\', '/')
Soviut