在django-ckeditor设置中通过“manage.py collectstatic”的最佳方法是什么?

时间:2014-01-31 21:08:28

标签: python django ckeditor django-staticfiles django-ckeditor

https://github.com/shaunsephton/django-ckeditor上,设置django-ckeditor的说明包括:

4。运行collectstatic管理命令:

$ ./manage.py collectstatic

此复制静态CKEditor需要将媒体资源放入STATIC_ROOT设置给出的目录中。有关更多信息,请参阅Django有关管理静态文件的文档。

然而,当我尝试这样做时,我收到一个错误:

$ python manage.py collectstatic
/usr/lib/python2.7/dist-packages/django/conf/__init__.py:221: DeprecationWarning: You have no filters defined on the 'mail_admins' logging handler: adding implicit debug-false-only filter. See http://docs.djangoproject.com/en/dev/releases/1.4/#request-exceptions-are-now-always-logged
  DeprecationWarning)


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
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 12: ordinal not in range(128)

我怎样才能最好地解决问题,以便django-ckeditor拥有它想要的静态文件?

在settings.py中,我现在有:

DIRNAME = os.path.dirname(__file__)

STATIC_ROOT = DIRNAME + '/static/'
print STATIC_ROOT

来自shell:

You are in a maze of twisted little Infocom parodies, all alike.
~/ccachicago > python manage.py collectstatic
/home/jonathan/ccachicago/static/
/home/jonathan/ccachicago/../ccachicago/static/
/usr/lib/python2.7/dist-packages/django/conf/__init__.py:221: DeprecationWarning: You have no filters defined on the 'mail_admins' logging handler: adding implicit debug-false-only filter. See http://docs.djangoproject.com/en/dev/releases/1.4/#request-exceptions-are-now-always-logged
      DeprecationWarning)


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
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 12: ordinal not in range(128)

You are in a maze of twisted little Infocom parodies, all alike.
~/ccachicago >

我很谨慎地说,“我做不到”,但我在Unix上长大,只会在这个Ubuntu服务器上使用传统的Unix文件名字符。

我不明白为什么我会提供任何传统上不属于Unix文件名的字符,而且似乎只报告传统的Unix文件名。

还有其他方法可以绊倒非ASCII字符吗?让我们假设我在Unix与智能引号,重音字符等不相容的所有地方都只使用了ASCII字符。

2 个答案:

答案 0 :(得分:0)

看起来你的django项目的静态文件中有一个路径/文件,它有一个非ascii文件名。您将不得不查看您的静态文件并根除原因。我不认为无论如何实际生成静态文件列表(比如在collectstatic上使用--dry-run选项)而不会导致该错误。

答案 1 :(得分:0)

请参阅: https://code.djangoproject.com/ticket/20375

问题是unicode数据INSIDE你的一个文件......不是文件名。如票中所示,将线包裹在: https://github.com/django/django/blob/1.4/django/contrib/staticfiles/storage.py#L172 使用str()更正问题并允许 collectstatic 完成。