__init__() missing 1 required positional argument

前端 未结 6 1663
死守一世寂寞
死守一世寂寞 2020-12-06 09:35

I am trying to learn Python. This is a really simple code. All I am trying to do here is to call a class\'s constructor. Initialize some variables there and print that varia

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-06 10:06

    If error is like Author=models.ForeignKey(User, related_names='blog_posts') TypeError:init() missing 1 required positional argument:'on_delete'

    Then the solution will be like, you have to add one argument Author=models.ForeignKey(User, related_names='blog_posts', on_delete=models.DO_NOTHING)

提交回复
热议问题