Django 自定义命令在 Eclipse 中不起作用
我最近对我的开发环境做了一些更改,遇到了一个问题。我在 eclipse 中有一个 Django 项目(通过 Aptana 插件使用 Pydev),但我无法使用任何自定义 django 命令。
如果我尝试运行自定义命令,我会得到以下输出:
Unknown command: 'resetdb'
Type 'manage.py help' for usage.
...但是如果我从命令行运行该命令,它就会起作用。
我尝试过调试,看看为什么自定义命令不运行,看起来 django 找不到
,但我不确定为什么这以前有效。
关于为什么我无法让自定义命令工作有什么想法吗?
如果任何软件(而不是我的项目)出现问题,我有以下设置:
- Eclipse Galileo (3.5.2)
- Django 1.3
- Aptana Studio 3.0.6
- Python 2.6
- Ubuntu 10.10
编辑:
项目结构如下:
- 项目/
- src/
- 主要/
- 管理/
- 命令/
- 自定义命令.py
- 命令/
- 管理.py
- 设置.py
- 管理/
- 主要/
- src/
安装的应用程序:
INSTALLED_APPS = (
'Main', # Enables us to use custom commands
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
#... plus apps for the project
)
I recently made some changes to my development environment and came across a problem. I have a Django project in eclipse (using Pydev through the Aptana plugin), and I haven't been able to use any of my custom django commands.
If I try to run a custom command, I get the following output:
Unknown command: 'resetdb'
Type 'manage.py help' for usage.
...But if I run the command from the command line, it works.
I've tried debugging, to see why the custom command doesn't run, and it looks like django can't find <project_name>.management
, but I'm not sure why this previously worked.
Any ideas as to why I can't get custom commands working?
In case it's a problem with any of the software (and not my project), I have the following setup:
- Eclipse Galileo (3.5.2)
- Django 1.3
- Aptana Studio 3.0.6
- Python 2.6
- Ubuntu 10.10
EDIT:
Project structure is as follows:
- Project/
- src/
- Main/
- management/
- commands/
- custom_command.py
- commands/
- manage.py
- settings.py
- management/
- Main/
- src/
Installed Apps:
INSTALLED_APPS = (
'Main', # Enables us to use custom commands
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
#... plus apps for the project
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您从 Eclipse 运行自定义命令时,请确保使用正确的 settings.py 文件来启动环境。如果 Eclipse 以某种方式使用未列出您的应用程序的默认 settings.py 调用该命令,则这就是您将看到的效果。
When you run your custom commands from Eclipse, make sure the correct settings.py file is being used to start the environment. If Eclipse is somehow invoking the command with a default settings.py that doesn't have your apps listed, this is the effect you would see.