djangogirlsをdjango2.0で挑戦中です。
以下のコード入力で、
AttributeError: module 'django.db.models' has no attribute 'CASCAD'
とのエラーが発生します。
Django2ではForeighKeyの引数にon_deleteを渡すとのことで直しましたがエラー継続します。解消方法ご教授下さい。```python
コード
from
1from django.utils import timezone 2 3class Post(models.Model): 4 author = models.ForeignKey('auth.User',on_delete=models.CASCAD) 5 title = models.CharField(max_length=200) 6 text = models.TextField() 7 created_date = models.DateTimeField(default=timezone.now) 8 published_date = models.DateTimeField(blank=True,null=True) 9 10 def publish(self): 11 self.published_date = timezone.now() 12 self.save() 13 14 def __str__(self): 15 return self.title
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/09/15 15:52