【发布时间】:2013-02-23 14:58:19
【问题描述】:
如何取消链接泛型关系?
我只想取消 Note 和 Customer 的链接。
models.py
class Note(models.Model):
contents = models.TextField()
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey('content_type', 'object_id')
class Customer(models.Model):
name = models.CharField(max_length=50, unique=True,)
notes = generic.GenericRelation(Note, null=True)
和
>>> cs=Customer.objects.get(pk=1)
>>> cs.notes.all()[0].delete()
但是cs.notes.all()[0] 被完全删除了。
我不想完全删除。我只是想取消链接...
我该怎么办?
【问题讨论】:
标签: django django-1.4