2015-10-15 79 views
2

我使用的是過去曾使用過的AWS S3的django-storages。但是,對於Microsoft Azure,我遇到了在Google上沒有任何結果的錯誤。使用azure作爲Django的存儲後端(使用django-storages)

我正在開發使用python 3和Django 1.8.4。我正在使用django-storages和django-storage-redux for python 3支持。

當調用./manage.py collectstatic並進入yes我得到兩個錯誤(!):

Traceback (most recent call last): 
    File "/Users/mac/.virtualenvs/bratwurst/lib/python3.4/site-packages/storages/backends/azure_storage.py", line 44, in exists 
    self.connection.get_blob_properties(
    File "/Users/mac/.virtualenvs/bratwurst/lib/python3.4/site-packages/storages/backends/azure_storage.py", line 34, in connection 
    self._connection = azure.storage.BlobService(
AttributeError: 'module' object has no attribute 'BlobService' 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
    File "./manage.py", line 10, in <module> 
    execute_from_command_line(sys.argv) 
    File "/Users/mac/.virtualenvs/bratwurst/lib/python3.4/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line 
    utility.execute() 
    File "/Users/mac/.virtualenvs/bratwurst/lib/python3.4/site-packages/django/core/management/__init__.py", line 330, in execute 
    self.fetch_command(subcommand).run_from_argv(self.argv) 
    File "/Users/mac/.virtualenvs/bratwurst/lib/python3.4/site-packages/django/core/management/base.py", line 393, in run_from_argv 
    self.execute(*args, **cmd_options) 
    File "/Users/mac/.virtualenvs/bratwurst/lib/python3.4/site-packages/django/core/management/base.py", line 444, in execute 
    output = self.handle(*args, **options) 
    File "/Users/mac/.virtualenvs/bratwurst/lib/python3.4/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 168, in handle 
    collected = self.collect() 
    File "/Users/mac/.virtualenvs/bratwurst/lib/python3.4/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 107, in collect 
    handler(path, prefixed_path, storage) 
    File "/Users/mac/.virtualenvs/bratwurst/lib/python3.4/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 305, in copy_file 
    if not self.delete_file(path, prefixed_path, source_storage): 
    File "/Users/mac/.virtualenvs/bratwurst/lib/python3.4/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 218, in delete_file 
    if self.storage.exists(prefixed_path): 
    File "/Users/mac/.virtualenvs/bratwurst/lib/python3.4/site-packages/storages/backends/azure_storage.py", line 46, in exists 
    except azure.WindowsAzureMissingResourceError: 
AttributeError: 'module' object has no attribute 'WindowsAzureMissingResourceError' 

我跟着使用Django的儲存與蔚藍here微薄的指令。

任何想法什麼可能會導致此錯誤?有沒有人成功部署了一個django 1.8應用程序,其中azure作爲存儲和靜態文件後端?

編輯:我已經破解周圍的Django的存儲器模塊中的位: 使用

import azure.storage.blob 
self._connection = azure.storage.blob.blobservice.BlobService(

,而不是僅僅

self._connection = azure.storage.BlobService(

但現在我得到不同的錯誤,這使得我相信這個問題實際上更深入。

回答

0

由於您在我們的存儲庫之上使用存儲平臺,因此我們的支持可能會受到限制。它看起來像改變了重新組織和重命名python客戶端庫的一部分,並且您使用的「Azure-Storage」平臺沒有更新他們的工具。其他人也有使用此平臺的類似問題。請參閱針對Django的儲存提交的以下問題:
https://bitbucket.org/david/django-storages/issues/225/azure-storages-are-incorrectly-imported

審查你的Django解決方案的「後端」文件時,它看起來像這樣爲您提供非常小的方便了而直接使用我們的存儲服務。您可能需要考慮使用我們的庫,因爲它可以爲您提供數據存儲的最大靈活性。如果你喜歡使用Django存儲,你可以聯繫他們,看看他們是否會修復它或分叉他們的代碼庫,並自己修復。你可以在這裏看到我們正在做的改進這個庫的所有工作: https://github.com/Azure/azure-storage-python/tree/dev

謝謝!

相關問題