Django 1.10:S3上的Djangostorages错误:不是naivedatetime(已经设置了tzinfo)

2024-05-15 20:51:50 发布

您现在位置:Python中文网/ 问答频道 /正文

自从升级到django1.10后,我开始遇到一个错误。我在python3.5上运行django1.10,其中包含django-storages==1.5.0和{}。在

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_TZ更改为False会改变错误,但我仍然不确定为什么会出现这种情况(这对我来说是Django代码库中的新领域):

^{pr2}$

你知道这是什么原因吗?在


Tags: djangoinpyselfhomelibpackagesline
1条回答
网友
1楼 · 发布于 2024-05-15 20:51:50

更新:

我正在更新我自己的答案,因为这个请求现在已经合并了。要修复,只需在requirements.txtpip install命令中使用版本1.5.1

django-storages==1.5.1

过时的上下文答案:

我已经找到了一个临时的解决办法,这应该是一个永久的解决办法。在

经过更多的侦查,一个朋友发现了这个他们认为可能相关的公关:https://github.com/jschneier/django-storages/pull/181

我注意到pull请求的日期是在我运行的最新django storages发行版(1.5.0)之后的两天。在我的requirements.txt中,我只是这样做的,指向提交的哈希:

^{pr2}$

然后,pip install upgrade -r requirements.txt并再次运行collectstatic,没有更多错误!{1.5版本中的修改也会包括在这个版本中。在

相关问题 更多 >