如果我要删除一个联系人对象,则相关的取消订阅对象应该级联删除。看来情况并非如此,为什么呢?下面看到的 Contact 模型有什么问题吗?谢谢你。
退订
class Unsubscribe(models.Model):
"""
Notes:
See: http://www.screamingatmyscreen.com/2012/6/django-and-generic-relations/
"""
content_type = models.ForeignKey(ContentType, help_text="Represents the name of the model")
object_id = models.PositiveIntegerField(help_text="stores the object id")
content_object = generic.GenericForeignKey('content_type', 'object_id')
reason = models.CharField(max_length=60)
request_made = models.DateTimeField(auto_now_add=True,
help_text="Shows when object was created.")
接触:
class Contact(models.Model):
first_name = models.CharField(max_length=60, blank=True)
last_name = models.CharField(max_length=60, blank=True)
created = models.DateTimeField(auto_now_add=True, help_text="Shows when object was created.")
objects = ContactManager()
#FK
group = models.ForeignKey(Group, related_name='contacts', blank=True, null=True)
contact_owner = models.ForeignKey(User)