Python 属性错误:';模块';对象没有属性';命令';
我正在使用django 1.7,我创建了以下管理命令: 文件结构:Python 属性错误:';模块';对象没有属性';命令';,python,django,Python,Django,我正在使用django 1.7,我创建了以下管理命令: 文件结构: app/ __init__.py management/ __init__.py commands/ __init__.py modal_asign.py 代码: 当我试图用python manage.py modal\u asign Traceback (
app/
__init__.py
management/
__init__.py
commands/
__init__.py
modal_asign.py
代码:
当我试图用python manage.py modal\u asign
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/rafael/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/home/rafael/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/rafael/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 238, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/home/rafael/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 42, in load_command_class
return module.Command()
AttributeError: 'module' object has no attribute 'Command'
回溯(最近一次呼叫最后一次):
文件“manage.py”,第10行,在
从命令行(sys.argv)执行命令
文件“/home/rafael/venv/local/lib/python2.7/site packages/django/core/management/_init__.py”,第385行,从命令行执行
utility.execute()
文件“/home/rafael/venv/local/lib/python2.7/site packages/django/core/management/_init__.py”,第377行,在execute中
self.fetch_命令(子命令)。从_argv(self.argv)运行_
文件“/home/rafael/venv/local/lib/python2.7/site-packages/django/core/management/_-init___.py”,第238行,在fetch_命令中
klass=加载命令类(应用程序名称,子命令)
文件“/home/rafael/venv/local/lib/python2.7/site packages/django/core/management/_init__.py”,第42行,装入命令类
返回module.Command()
AttributeError:“模块”对象没有“命令”属性
您的类名被称为Commands
,而django希望它被称为Command
。因此出现了错误
改变
class Commands(BaseCommand):
到
您的类名被称为
Commands
,而django希望它被称为Command
。因此出现了错误
改变
class Commands(BaseCommand):
到
class Command(BaseCommand):