from django.db import models
class Story(models.Model):
id = models.IntegerField(primary_key=True)
news_type = models.CharField(max_length=255,null=True)
category_id = models.CharField(max_length=255,null=True)
title = models.CharField(max_length=255,null=True)
created = models.DateTimeField(null=True)
author = models.CharField(max_length=255, null=True)
author_title = models.CharField(max_length=255, null=True)
image_caption = models.TextField(null=True)
image_credit = models.CharField(max_length=255,null=True)
image_full_url = models.CharField(max_length=255,null=True)
body = models.TextField(null=True)
summary = models.TextField(null=True)
video_id = models.CharField(max_length=255,null=True)
external_url = models.CharField(max_length=255,null=True)
order = models.IntegerField(null=True)
class StoryFactBox(models.Model):
story = models.ForeignKey('Story', null = True)
body = models.TextField()
class StoryKeyword(models.Model):
story = models.ForeignKey('Story', null = True)
keyword = models.CharField(max_length=255)
< p > models.ForeignKey('Story', null = True)
会引起哪些模式更改?
我正在阅读文档:
我想使用remove()和clear()方法,这是文档的一部分。
为了避免数据库不一致,仅当null=True时,此方法仅存在于ForeignKey对象上。如果无法将相关字段设置为None(NULL),则无法从关系中删除对象而不将其添加到另一个对象中。在上面的示例中,从b.entry_set()中删除e等效于执行e.blog = None,并且因为blog ForeignKey没有null=True,所以这是无效的。