簡體   English   中英

向導 django 2.1:__init__() 需要 1 個位置參數,但給出了 2 個

[英]Wizard django 2.1 : __init__() takes 1 positional argument but 2 were given

我使用 Django 2.1,我安裝了表單工具,我使用了向導模塊,目標是創建一個包含多個表單的 stepbystep 頁面。

我不知道我是否必須改變一些東西,但我已經在其他帖子中查找過,但不幸的是我沒有解決我的問題。

我有這個錯誤:

TypeError at /dashboard/createproject/

__init__() takes 1 positional argument but 2 were given

Request Method:     GET
Request URL:    http://localhost:8000/dashboard/createproject/
Django Version:     2.1.4
Exception Type:     TypeError
Exception Value:    __init__() takes 1 positional argument but 2 were given

Exception Location:     /home/user/Desktop/venv/lib/python3.6/site-packages/django/contrib/auth/decorators.py in _wrapped_view, line 21
Python Executable:  /home/user/Desktop/venv/bin/python
Python Version:     3.6.7
Python Path:    

['/home/user/Desktop',
 '/usr/lib/python36.zip',
 '/usr/lib/python3.6',
 '/usr/lib/python3.6/lib-dynload',
 '/home/user/Desktop/venv/lib/python3.6/site-packages',
 '/home/user/Desktop/venv/lib/python3.6/site-packages/setuptools-39.1.0-py3.6.egg']

Server time:    jeu, 31 Jan 2019 12:02:24 +0100

Django 表單不允許從 2.0 開始的位置參數,因為它記錄如下。

https://docs.djangoproject.com/en/3.0/releases/2.0/#backwards-incompatible-changes-in-2-0

表單字段不再接受可選參數作為位置參數 為了幫助防止由於表單字段參數順序不正確而導致的運行時錯誤,內置表單字段的可選參數不再被接受為位置參數。 例如:

forms.IntegerField(25, 10)

引發異常,應替換為:

forms.IntegerField(max_value=25, min_value=10)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM