Workaround:
A=models. ForeignKey (' BookInfo ', on_delete=models. CASCADE,)
That is, add on_delete=models after the foreign key value. CASCADE
Reason:
After django2.0, define the foreign key and a one-to-one relationship when you need to add on_delete option, this parameter in order to avoid the two table data inconsistency problem, otherwise will be error:
TypeError: __init__ () Missing 1 required positional argument: ' On_delete '
To illustrate:
User=models. Onetoonefield (User)
Owner=models. ForeignKey (UserProfile)
Need to change to:
User=models. Onetoonefield (user,on_delete=models. CASCADE)--in the old version this parameter (models. CASCADE) is the default value
Owner=models. ForeignKey (userprofile,on_delete=models. CASCADE)--in the old version this parameter (models. CASCADE) is the default value
Parameter description:
On_delete has cascade, PROTECT, Set_null, Set_default, SET () five selectable values
CASCADE: This value is set to cascade Delete.
PROTECT: This value is set to report integrity errors.
Set_null: This value is set to set the foreign key to NULL, provided that NULL is allowed.
Set_default: This value is set to the default value of the foreign key.
Set (): This value setting, which invokes the outside value, can be a function.
In general, the use of cascade is possible.
Django2.1 generate database tables based on models Times __init__ () Missing 1 required positional argument: ' On_delete '