2
1

More than 5 years have passed since last update.

【DjangoGirls】Djangoモデル「makemigrations blog」でエラーが出る

Last updated at Posted at 2018-10-03

Django girlsのチュートリアル(日本語版:https://djangogirlsjapan.gitbooks.io/workshop_tutorialjp/content/
の「Djangoモデル」トピックで
TypeError: __init__() missing 1 required positional argument: 'on_delete'

というエラーが出る場合の対処法を簡単にメモ。。。

Django2.0以降のバージョンで作業していると起こるエラーです。
blog/models.pyの5行目

author = models.ForeignKey('auth.User')


author = models.ForeignKey('auth.User', on_delete=models.CASCADE)

とするとエラーが解消されます。
Django 2.0からはForeignKeyのon_deleteが必須になったそうです。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1