在__init__中引发TypeError(“%s()得到一个意外的关键字参数'%s'”%(cls .__ name__,kwarg))

时间:2019-08-01 12:58:49

标签: python django

board = Board(name='Django', description='This is a board about Django.')    

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/babak/myproject/venv/lib/python3.6/site-packages/django/db/models/base.py", line 501, in __init__
    raise TypeError("%s() got an unexpected keyword argument '%s'" % (cls.__name__, kwarg))
TypeError: Board() got an unexpected keyword argument 'description'

1 个答案:

答案 0 :(得分:-1)

函数Board不能将description识别为参数。 也就是说,您的函数不接受相应的参数。

最好删除description参数。