DEFAULT_FILE_STORAGE settings conflict

103 views
Skip to first unread message

jackson...@gmail.com

unread,
Feb 26, 2009, 6:13:24 PM2/26/09
to Django users
I try to make my own custom storage like:

from django.core.files.storage import Storage

CUSTOM_MEDIA_ROOT = 'blah'
CUSTOM_MEDIA_URL = 'bleh'


class MediaStorage(Storage):
def __init__(self, location=CUSTOM_MEDIA_ROOT,
base_url=CUSTOM_MEDIA_URL, *args, **kwargs):
super(MediaStorage, self).__init__(*args, **kwargs)
self.location = os.path.abspath(location)
self.base_url = base_url


, but when i put that custom storage in the settings:

DEFAULT_FILE_STORAGE = 'path_to_my_custom_storage'.MediaStorage

and i try to restore the database django raise this error:

...
from django.core.files.storage import Storage
File "/usr/lib/python2.5/django/core/files/storage.py", line 118, in
<module>
class FileSystemStorage(Storage):
File "/usr/lib/python2.5/django/core/files/storage.py", line 124, in
FileSystemStorage
def __init__(self, location=settings.MEDIA_ROOT,
base_url=settings.MEDIA_URL):
File "/usr/lib/python2.5/django/conf/__init__.py", line 28, in
__getattr__
self._import_settings()
File "/usr/lib/python2.5/django/conf/__init__.py", line 57, in
_import_settings
raise ImportError("Settings cannot be imported, because
environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable
DJANGO_SETTINGS_MODULE is undefined.

Somebody help?

Alex Gaynor

unread,
Feb 26, 2009, 6:38:23 PM2/26/09
to django...@googlegroups.com
That's probably because DEFAULT_FILE_STORAGE = 'path_to_my_custom_storage'.MediaStorage would be a typo, it should be 'path.to.storage.MediaStorage'.

Alex


--
"I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire
"The people's good is the highest law."--Cicero

Jackson Torres

unread,
Feb 27, 2009, 11:57:51 AM2/27/09
to django...@googlegroups.com
Thanx Alex :)
Reply all
Reply to author
Forward
0 new messages