【问题标题】:What is the best way to get past the "manage.py collectstatic" in django-ckeditor setup?在 django-ckeditor 设置中通过“manage.py collectstatic”的最佳方法是什么?
【发布时间】:2014-02-24 17:42:55
【问题描述】:

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

从外壳:

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 字符。

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

    • 谢谢;现在在问题结束时查看已编辑的材料。
    【解决方案2】:

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

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

    【讨论】:

      猜你喜欢
      • 2015-11-23
      • 2012-03-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-23
      • 1970-01-01
      • 2023-03-13
      • 2023-03-25
      相关资源
      最近更新 更多