【问题标题】:AttributeError: 'Settings' object has no attribute 'ADMIN_MEDIA_PREFIX'AttributeError:“设置”对象没有属性“ADMIN_MEDIA_PREFIX”
【发布时间】:2013-05-03 00:49:30
【问题描述】:

我正在尝试使用 ChainedForeignKey 制作一个智能菜单,但到目前为止我一直坚持使用 ChainedForeignKey 的导入:

from smart_selects.db_fields import ChainedForeignKey 

我在 Eclipse 上使用 pydev。 我在这里下载了智能选择包:http://pydoc.net/Python/django-smart-selects/1.0.2/ 并将其添加到我的PYTHONPATH

当我调试时我得到:

Traceback (most recent call last):
  File "C:\Users\Mr.Machine\Desktop\eclipse\plugins\org.python.pydev_2.7.0.2013032300\pysrc\pydevd.py", line 1397, in <module>
    debugger.run(setup['file'], None, None)
  File "C:\Users\Mr.Machine\Desktop\eclipse\plugins\org.python.pydev_2.7.0.2013032300\pysrc\pydevd.py", line 1090, in run
    pydev_imports.execfile(file, globals, locals) #execute the script
  File "C:\Users\Mr.Machine\Desktop\Workspace\Medbook\testApp\forms.py", line 4, in <module>
    from smart_selects.db_fields import ChainedForeignKey 
  File "C:\Users\Mr.Machine\Desktop\django-smart-selects-1.0.2\smart_selects\db_fields.py", line 2, in <module>
    import form_fields
  File "C:\Users\Mr.Machine\Desktop\django-smart-selects-1.0.2\smart_selects\form_fields.py", line 1, in <module>
    from smart_selects.widgets import ChainedSelect
  File "C:\Users\Mr.Machine\Desktop\django-smart-selects-1.0.2\smart_selects\widgets.py", line 20, in <module>
    class ChainedSelect(Select):
  File "C:\Users\Mr.Machine\Desktop\django-smart-selects-1.0.2\smart_selects\widgets.py", line 30, in ChainedSelect
    class Media:
  File "C:\Users\Mr.Machine\Desktop\django-smart-selects-1.0.2\smart_selects\widgets.py", line 33, in Media
    ('js/jquery.min.js', 'js/jquery.init.js')]
  File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 54, in __getattr__
    return getattr(self._wrapped, name)
AttributeError: 'Settings' object has no attribute 'ADMIN_MEDIA_PREFIX'

任何帮助表示赞赏

【问题讨论】:

  • 你能发布堆栈跟踪吗?
  • 文件“C:\Users\Mr.Machine\Desktop\Workspace\Medbook\testApp\forms.py”,第 4 行,在 from smart_selects.db_fields import ChainedForeignKey ImportError: No module named smart_selects.db_fields
  • 我在 Eclipse 上使用 pydev,我需要下载一些库吗?
  • 在settings.py中,试试:ADMIN_MEDIA_PREFIX='/static/'
  • 似乎成功了,现在没有错误了,谢谢!

标签: django import django-admin key chained


【解决方案1】:

将评论标记为答案以供将来参考:

看起来ADMIN_MEDIA_PREFIX 没有设置。

为 ADMIN 媒体设置 ADMIN_MEDIA_PREFIX='/static/' 或任何其他适当的值可以解决问题

【讨论】:

    猜你喜欢
    • 2020-05-19
    • 2012-10-02
    • 2020-11-06
    • 2022-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-02
    • 1970-01-01
    相关资源
    最近更新 更多