인프런 커뮤니티 질문&답변
on_delete must be callable 오류 질문
작성
·
174
0
from django.db import models
from django.contrib.auth.models import User
# Create your models here.
class Post(models.Model):
title = models.CharField(max_length=30)
content = models.TextField()
created = models.DateTimeField()
author = models.ForeignKey(User, on_delete=True)
blog 모델 소스
File "C:\Users\한글\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\fields\related.py", line 801, in __init__ raise TypeError('on_delete must be callable.') TypeError: on_delete must be callable.
오류메세지
계속 강의대로 하는데 python manage.py makemigrations blog 명령어가 먹히지 않습니다 ㅠ
답변 1
0
SungYong Lee
지식공유자
이 강의 영상이 업로드 된 이후에 django 새 버전이 나오면서 약간 달라졌습니다.
요는, on_delete=True가 아니라, on_delete=models.CASCADE라고 고쳐주면 됩니다. 다른 수강생 분도 며칠 전에 질문하셨어요.





