我需要检查为相同(content_type 和 object_id)添加的记录,以确保在保存时非复制到数据库中。
class objectHere(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.")
我正在考虑用 pre_save 做点什么?这可以做到吗,如果可以,怎么做?