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 |
'Django' 카테고리의 다른 글
csrf 및 form 구현 (0) | 2018.01.25 |
---|---|
[Django] 테이블 paginator (0) | 2018.01.22 |
[Django] model, 마이그레이션, 템플릿 (0) | 2018.01.18 |
Django로 앱 만드는 초기과정 (0) | 2018.01.18 |
django model (0) | 2018.01.09 |