python运行bat脚本 option input错误_Python属性运行脚本时出错:type object'BaseCommand'没有属性'option_list'...

在尝试使用Django 1.10和django-extensions 1.6.1运行Python脚本时遇到错误。问题在于`BaseCommand.option_list`在Django 1.8中已弃用,并在Django 1.10中移除。解决方案是升级到Django的最新稳定版本,如1.9.2,或者从django-extensions的master分支安装更新。
摘要由CSDN通过智能技术生成

I saw this post on how to run a python script from django: http://www.djangotutsme.com/how-to-run-python-script-from-django/

I tried the example but get the following error when running python manage.py runscript myscript.

I have Python 2.7, Django 1.10 and django extensions 1.6.1 installed.

Traceback (most recent call last):

File "manage.py", line 10, in

execute_from_command_line(sys.argv)

File "/usr/lib/python2.7/site-packages/Django-1.10.dev20151201151517-py2.7.egg/django/core/management/__init__.py", line 349, in execute_from_command_line

utility.execute()

File "/usr/lib/python2.7/site-packages/Django-1.10.dev20151201151517-py2.7.egg/django/core/management/__init__.py", line 341, in execute

self.fetch_command(subcommand).run_from_argv(self.argv)

File "/usr/lib/python2.7/site-packages/Django-1.10.dev20151201151517-py2.7.egg/django/core/management/__init__.py", line 193, in fetch_command

klass = load_command_class(app_name, subcommand)

File "/usr/lib/python2.7/site-packages/Django-1.10.dev20151201151517-py2.7.egg/django/core/management/__init__.py", line 40, in load_command_class

module = import_module('%s.management.commands.%s' % (app_name, name))

File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module

__import__(name)

File "/usr/lib/python2.7/site-packages/django_extensions-1.6.1-py2.7.egg/django_extensions/management/commands/runscript.py", line 6, in

from django_extensions.management.email_notifications import \

File "/usr/lib/python2.7/site-packages/django_extensions-1.6.1-py2.7.egg/django_extensions/management/email_notifications.py", line 10, in

class EmailNotificationCommand(BaseCommand):

File "/usr/lib/python2.7/site-packages/django_extensions-1.6.1-py2.7.egg/django_extensions/management/email_notifications.py", line 49, in EmailNotificationCommand

**option_list = BaseCommand.option_list + (

AttributeError: type object 'BaseCommand' has no attribute 'option_list'**

Any idea what the problem is? Is this a bug in django?

解决方案

BaseCommand.option_list is deprecated in Django 1.8 and removed in Django 1.10. It looks like Django-extensions has been updated, but there hasn't been a new release since then.

You could try installing django-extensions from the master branch, but it would be a better idea to use the latest release of Django, currently 1.9.2.

Django 1.10 has not been released yet, and is still under development.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值