简体   繁体   English

TypeError: __init__() 得到了一个意外的关键字参数 'method'

[英]TypeError: __init__() got an unexpected keyword argument 'method'

Well, I am writing a Flask project, but when I tried to python manage.py好吧,我正在写一个 Flask 项目,但是当我尝试python manage.py

The traceback told me that:回溯告诉我:

Traceback (most recent call last):
  File "manage.py", line 5, in <module>
    from app import db,create_app
  File "/home/humbert/2017-sharing-backend/sharing/app/__init__.py", line 42, in <module>
    app.register_blueprint(main_blueprint, url_prefix='/main')
  File "/home/humbert/venv/local/lib/python2.7/site-packages/flask/app.py", line 64, in wrapper_func
    return f(self, *args, **kwargs)
  File "/home/humbert/venv/local/lib/python2.7/site-packages/flask/app.py", line 951, in register_blueprint
    blueprint.register(self, options, first_registration)
  File "/home/humbert/venv/local/lib/python2.7/site-packages/flask/blueprints.py", line 154, in register
    deferred(state)
  File "/home/humbert/venv/local/lib/python2.7/site-packages/flask/blueprints.py", line 173, in <lambda>
    s.add_url_rule(rule, endpoint, view_func, **options))
  File "/home/humbert/venv/local/lib/python2.7/site-packages/flask/blueprints.py", line 76, in add_url_rule
    view_func, defaults=defaults, **options)
  File "/home/humbert/venv/local/lib/python2.7/site-packages/flask/app.py", line 64, in wrapper_func
    return f(self, *args, **kwargs)
  File "/home/humbert/venv/local/lib/python2.7/site-packages/flask/app.py", line 1043, in add_url_rule
    rule = self.url_rule_class(rule, methods=methods, **options)
TypeError: __init__() got an unexpected keyword argument 'method'

I think my manage.py is right,and I can't figure out the mistake.我认为我的manage.py是正确的,我无法找出错误。

The mistake part of __init__.py is that: __init__.py的错误部分是:

from .main import main as main_blueprint
app.register_blueprint(main_blueprint, url_prefix='/main')

from .auth import auth as auth_blueprint
app.register_blueprint(auth_blueprint, url_prefix="/auth")

from . import views

I really need some help, thanks!我真的需要一些帮助,谢谢!

I had a similar problem.我有一个类似的问题。 In my code I had a line @bp.route('/<init:id>/delete', method=('POST')) The keyword method needs to be changed to methods(with an s)在我的代码中,我有一行@bp.route('/<init:id>/delete', method=('POST'))关键字 method needs to be changed to methods(with an s)

I had encountered a similar problem in my code and just had to change the keyword " method " to " methods ":我在我的代码中遇到过类似的问题,只需要将关键字“ method ”更改为“ methods ”:

@app.route('/login', methods = ['GET', 'POST'])

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TypeError at &#39;&#39; __init__() 得到一个意外的关键字参数 &#39;&#39; - TypeError at '' __init__() got an unexpected keyword argument '' Scrapy错误:TypeError:__ init __()得到一个意外的关键字参数&#39;deny&#39; - Scrapy Error: TypeError: __init__() got an unexpected keyword argument 'deny' TypeError:__init __()得到了意外的关键字参数错误 - TypeError: __init__() got an unexpected keyword argument error TypeError:__ init __()在argparse中有一个意外的关键字参数&#39;type&#39; - TypeError: __init__() got an unexpected keyword argument 'type' in argparse 图片/创建时发生TypeError-__init __()得到了意外的关键字参数&#39;save&#39; - TypeError at images/create - __init__() got an unexpected keyword argument 'save' TypeError:__init __()获得了意外的关键字参数&#39;n_components&#39; - TypeError: __init__() got an unexpected keyword argument 'n_components' TypeError:__init __()获得了意外的关键字参数&#39;cv&#39; - TypeError: __init__() got an unexpected keyword argument 'cv' TypeError:__ init __()得到一个意外的关键字参数&#39;delay&#39; - TypeError:__init__() got an unexpected keyword argument 'delay' TypeError: __init__() 得到了一个意想不到的关键字参数 'many' - TypeError: __init__() got an unexpected keyword argument 'many' TypeError:__ init __()得到一个意外的关键字参数&#39;log_dir&#39; - TypeError: __init__() got an unexpected keyword argument 'log_dir'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM