错误:django 1.3.1 中没有名为 staticfiles 的模块 +蟒蛇2.6?怎么了

发布于 2024-12-23 07:03:10 字数 441 浏览 2 评论 0原文

我已经有几天没有在 django 项目上工作了,现在我回来了,但我无法继续工作。当我在 eclipse aptana 中调试或运行时,出现“错误:没有名为 staticfiles 的模块”错误。

  • 我什至已经将 aptana 更新到今天的更新,但没有运气。
  • 我已经卸载了django,删除所有文件并重新安装。
  • 如果我在cmd(在Windows上)中使用python导入django,它就在我期望的位置

但是如果我从settings.py中删除“INSTALLED_APPS”中的“'django.contrib.staticfiles'”字符串,一切正常,但是正如预期的那样,我无法访问静态文件。

那时我已经安装了 Google 应用引擎 + python 2.5;这可能是问题所在以及如何解决?

非常感谢*

I didn't worked on the django project for somedays and now I return and I can't work on it. When I debug or run in eclipse aptana I get the "Error: No module named staticfiles" error.

  • I have even updated aptana to today's updates and no luck.
  • I have uninstalled the django, delete all files and reinstall.
  • If I import django with python in cmd (on windows) it is in the place I expect to be

But if I delete the "'django.contrib.staticfiles'," string in the "INSTALLED_APPS" from settings.py everything works fine but I have no access to the static files, as expected..

In those days I have installed Google app engine + python 2.5; can this be the problem and how to solve?

thank you very much*

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

初与友歌 2024-12-30 07:03:10

以下是我找出问题所采取的步骤:

  • 验证它在命令行(Windows 中的 cmd.exe)中是否正常工作 - 只是为了消除与 Aptana 相关的问题。您需要执行以下操作:C:\Path\to\Python2.6\python.exe manage.py runserver(注意:选择任何将检查您的settings.py的管理命令)。 你还没有在Python2.6中安装Django 1.3.1(你可以安装它,或者你可以设置一个新的virtualenv,见下文)
  • 如果这给出了同样的错误,那么当你在命令中使用它时, 行,您只需确保 aptana 使用正确的解释器路径。您需要检查您是否已正确定义它(在全局首选项(工作区设置)中 - pydev python 解释器),然后在特定项目中使用它 - (检查它正在使用 python 解释器的项目设置你刚刚定义)
  • 注意:Django 1.3.1可以使用python2.5,但不能使用下一个版本的django

以下是我将来如何避免这种情况的方法:

  • 使用virtualenv [1]来避免依赖于安装历史记录的任意性质(一次如果你已经在任何版本的 python 中安装了 virtualenv,那么你可以在设置 virtualenv 时指定哪个 python: virtualenv -p C:\Path\to\Python2.6\python.exe )。
  • 使用 virtualenv --no-site-packages 确保本地没有依赖项
  • 使用 pip[2] 安装所有 python 软件包(具有二进制内容的软件包可能会出现问题 - 使用 easy_install )
  • 使用 pip freeze > requirements.txt 来记录您的依赖项(并将此文件添加到源代码控制中)

[1] http:// pypi.python.org/pypi/virtualenv

[2] http://pypi.python.org /pypi/pip

注意 pip 和 easy_install 会自动安装到您的新 virtualenv 中

Here are the steps I'd take to find out the problem:

  • verify that it's working correctly in the command-line (cmd.exe in windows) - just to remove the issues associated with Aptana. You need to do something like: C:\Path\to\Python2.6\python.exe manage.py runserver (NB: choose any management command that will check your settings.py). If this gives the same error, then you haven't got Django 1.3.1 installed in Python2.6 (you could install it, or you could set up a fresh virtualenv, see below)
  • once you've got it working in the command line, you just have to make sure that aptana is using the correct interpreter path. You need to check that you've defined it correctly (in your global preferences (the workspace settings) -- pydev python interpreter) and then are using it in the specific project -- (check the project settings that it is using the python interpreter you just defined )
  • NB: Django 1.3.1 can use python2.5, but not next version of django

Here is how I would avoid this in future:

  • use virtualenv[1] to avoid being dependent on the arbitrary nature of your installation history (once you've installed virtualenv in ANY version of python you can then specify which python when you set up the virtualenv: virtualenv -p C:\Path\to\Python2.6\python.exe ).
  • use virtualenv --no-site-packages to ensure you have no dependencies locally
  • use pip[2] to install all your python packages (problems may occur with packages with binary content - use easy_install for those)
  • use pip freeze > requirements.txt to record your dependencies (and add this file into your source code control)

[1] http://pypi.python.org/pypi/virtualenv

[2] http://pypi.python.org/pypi/pip

NB pip and easy_install are automatically installed into your new virtualenv

゛时过境迁 2024-12-30 07:03:10

使用 {% load static %} 而不是 {% load staticfiles %}
在新版本的Django中,加载静态文件的语法发生了变化

use {% load static %} instead of {% load staticfiles %}
in the new version of Django, the syntax of loading static files changed

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文