0

I have taken over a project that uses django cumulus for cloud storage. On my development machine, some times I use a slow internet connection, and every time I save a change, django recompiles and tries to make a connection to the racksapace store

Starting new HTTPS connection (1): identity.api.rackspacecloud.com

This sometimes takes 15 seconds and is a real pain. I read a post where someone said they turned off cumulus for local development. I think this was done by setting

DEFAULT_FILE_STORAGE

but unfortunately the poster did not specify. If someone knows a simple setting I can put in my local settings to serve media and static files from my local machine and stop django trying to connect to my cloud storage on every save, that is what I want to do.

MagicLAMP
  • 1,032
  • 11
  • 26

2 Answers2

0

Yeah it looks like you should just need the DEFAULT_FILE_STORAGE to be default value, which is django.core.files.storage.FileSystemStorage according to the source code.

However, a better approach would be to not set anything in your local settings and set the DEFAULT_FILE_STORAGE and CUMULUS in a staging_settings.py or prod_settings.py file.

awwester
  • 9,623
  • 13
  • 45
  • 72
  • Thanks for the info, but setting DEFAULT_FILE_STORAGE to that value does not fix it, and if I remove the settings altogether for that and CUMULUS, I get authentication errors. It still tries to connect to the remote cloud storage. It does not seem be be a middle ware thing either :( – MagicLAMP Apr 16 '16 at 06:31
0

The constant reloading of the rackspace bucket was because the previous developer had

from cumulus.storage import SwiftclientStorage
class PrivateStorage(SwiftclientStorage):

and in models.py

from common.storage import PrivateStorage
PRIVATE_STORE = PrivateStorage()
...
class Upload(models.Model):
    upload = models.FileField(storage=PRIVATE_STORE, upload_to=get_upload_path)

This meant every time the project reloaded, it would create a new https connection to rackspace, and time out if the connection was poor. I created a settings flag to control this by putting the import of SwiftclientStorage and defining of PrivateStorage like so

from django.conf import settings
if settings.USECUMULUS:
    from cumulus.storage import SwiftclientStorage

    class PrivateStorage(SwiftclientStorage):
...
else:
    class PrivateStorage():
        pass
MagicLAMP
  • 1,032
  • 11
  • 26