2016-08-30 5 views
0

自升級到Django 1.10以來,我開始出現錯誤。我在Python 3.5上運行Django 1.10,使用django-storages==1.5.0boto3==1.4.0Django 1.10:在S3上的Django存儲錯誤:不天真的日期時間(tzinfo已設置)

You have requested to collect static files at the destination 
location as specified in your settings. 

This will overwrite existing files! 
Are you sure you want to do this? 

Type 'yes' to continue, or 'no' to cancel: yes 
Traceback (most recent call last): 
    File "./manage.py", line 10, in <module> 
    execute_from_command_line(sys.argv) 
    File "/home/vagrant/.virtualenvs/wrds-classroom/lib/python3.5/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line 
    utility.execute() 
    File "/home/vagrant/.virtualenvs/wrds-classroom/lib/python3.5/site-packages/django/core/management/__init__.py", line 359, in execute 
    self.fetch_command(subcommand).run_from_argv(self.argv) 
    File "/home/vagrant/.virtualenvs/wrds-classroom/lib/python3.5/site-packages/django/core/management/base.py", line 305, in run_from_argv 
    self.execute(*args, **cmd_options) 
    File "/home/vagrant/.virtualenvs/wrds-classroom/lib/python3.5/site-packages/django/core/management/base.py", line 356, in execute 
    output = self.handle(*args, **options) 
    File "/home/vagrant/.virtualenvs/wrds-classroom/lib/python3.5/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 193, in handle 
    collected = self.collect() 
    File "/home/vagrant/.virtualenvs/wrds-classroom/lib/python3.5/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 124, in collect 
    handler(path, prefixed_path, storage) 
    File "/home/vagrant/.virtualenvs/wrds-classroom/lib/python3.5/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 337, in copy_file 
    if not self.delete_file(path, prefixed_path, source_storage): 
    File "/home/vagrant/.virtualenvs/wrds-classroom/lib/python3.5/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 258, in delete_file 
    target_last_modified = self.storage.get_modified_time(prefixed_path) 
    File "/home/vagrant/.virtualenvs/wrds-classroom/lib/python3.5/site-packages/django/core/files/storage.py", line 231, in get_modified_time 
    return _possibly_make_aware(dt) 
    File "/home/vagrant/.virtualenvs/wrds-classroom/lib/python3.5/site-packages/django/core/files/storage.py", line 243, in _possibly_make_aware 
    return timezone.make_aware(dt, tz).astimezone(timezone.utc) 
    File "/home/vagrant/.virtualenvs/wrds-classroom/lib/python3.5/site-packages/django/utils/timezone.py", line 368, in make_aware 
    return timezone.localize(value, is_dst=is_dst) 
    File "/home/vagrant/.virtualenvs/wrds-classroom/lib/python3.5/site-packages/pytz/tzinfo.py", line 304, in localize 
    raise ValueError('Not naive datetime (tzinfo is already set)') 
ValueError: Not naive datetime (tzinfo is already set) 

量變到質變USE_TZFalse改變了錯誤,但我仍然不知道爲什麼這被引起的(這是在Django的代碼庫的新領域對我來說):

TypeError: can't compare offset-naive and offset-aware datetimes 

任何想法這裏的原因是什麼?

回答

0

UPDATE:

我更新我自己的答案,因爲這拉動請求已經被合併。要解決,只需在您的requirements.txtpip install命令使用版本1.5.1:上下文DATE答案

django-storages==1.5.1 

OUT:

我已經想通了一個臨時的解決辦法應導致永久性的修復。

一些偵探後,朋友發現這個PR他們認爲可能與:https://github.com/jschneier/django-storages/pull/181

我注意到拉入請求的日期是最新的Django的存儲器版本(1.5.0)兩天後,我正在運行。在我的requirements.txt我只是這樣做,在提交的哈希指出:

#django-storages==1.5.0 
git+https://github.com/jschneier/django-storages.git#5f280571ee1ae93ee66ed805b53b08bfe5ab9f0c 
boto3==1.4.0 

然後,pip install --upgrade -r requirements.txt並再次運行collectstatic,並沒有更多的錯誤!我猜這個修補程序將包含在1.5.1版本中,在這一點上,我將再次更改我的requirements.txt

相關問題