Django
[Django] TypeError : __init__() missing 1 required positional argument: 'on_delete' 에러
이농이능
2018. 1. 22. 10:11
Django model에 foreignkey 설정을 하는 코드를 넣었더니 migration 할 때
TypeError: __init__() missing 1 required positional argument: 'on_delete'
에러가 생겨서 알아본 결과,
on_delete를 설정해줘야 한다고 해서 했더니 에러가 고쳐졌당
You can change the property categorie
of the class Article
like this:
1 2 3 4 | categorie = models.ForeignKey( 'Categorie', on_delete=models.CASCADE, ) | cs |
and the error should disappear.
Eventually you might need another option for on_delete
, check the documentation for more details:
https://docs.djangoproject.com/en/1.11/ref/models/fields/#django.db.models.ForeignKey
EDIT:
As you stated in your comment, that you don't have any special requirements for on_delete
, you could use the option DO_NOTHING
:
1 2 3 | # ... on_delete=models.DO_NOTHING, # ... | cs |