Вставка с 1 внешним ключом и 2 пк не удалась
class TbBoard(models.Model):
board_seq = models.BigAutoField(primary_key=True)
board_title = models.CharField(max_length=30)
board_content = models.CharField(max_length=2000, blank=True, null=True)
board_writer = models.CharField(max_length=40)
board_password = models.CharField(max_length=200)
create_date = models.DateTimeField(default=timezone.now)
class Meta:
managed = False
db_table = 'tb_board'
class TbComment(models.Model):
board_seq = models.ForeignKey(TbBoard, models.DO_NOTHING, db_column='board_seq')
comment_seq = models.IntegerField(primary_key=True)
comment_depth = models.IntegerField()
comment_content = models.CharField(max_length=2000)
comment_writer = models.CharField(max_length=40)
comment_password = models.CharField(max_length=200)
create_date = models.DateTimeField(default=timezone.now)
class Meta:
managed = False
db_table = 'tb_comment'
unique_together = ('board_seq', 'comment_seq', 'comment_depth',)
Сохраняемая часть выглядит следующим образом.
tb_comment = models.TbComment(
board_seq = models.TbComment.objects.get(board_seq=board_seq),
comment_seq = comment_seq,
comment_depth = comment_depth,
comment_content = comment_content,
comment_writer = comment_writer,
comment_password = comment_password,
)
board_seq=1, comment_seq=0, comment_depth=0 В состоянии, которое вставляется в эту базу данных
board_seq=2, comment_seq=0, comment_depth=0 Я пытаюсь вставить
board_seq=1 -> 2, comment_seq=0, comment_depth=0 будет перезаписана по
как я могу решить эту проблему?
force_insert=true? При попытке уже существующий ключ(0, 0) выводится следующим образом.