django - 如何在 Django 中为历史表设置自动生成的元字段
问题描述
样品模型
from simple_history.models import HistoricalRecords()
class Sample(models.Model):
company = models.CharField(max_length=100,null=True,blank=True)
history = HistoricalRecords()
在上面的模型中,我使用了HistoricalRecords
from django-simple-history来保存每个实例的更改历史Sample
问题
history_user
无法填充错误消息:**Error** : 1452, 'Cannot add or update a child row: a foreign key constraint fails,REFERENCES auth_user (id)
如何在实例中设置history_change_reason
and ?history_user_id
HistoricalRecords()
编辑:尝试过这个解决方案:链接
解决方案
推荐阅读
- excel - 功能颜色匹配特定条件的单元格
- amazon-web-services - 在本地运行 Amazon EventBridge
- vue.js - 尝试将输入元素绑定到vue页面中的数据值
- json - 将json转换为飞镖
- javascript - 如何在 Selenium Webdriver 中使用 Java Script 中的 for 循环单击 n 次
- javascript - 不确定为什么 .load() 完成事件不起作用
- php - 使用准备好的语句时如何指定日期作为输入
- python - Python中1.3+0.13的计算
- php - PHP http_response_code($code) 在完全错误的 if 语句中执行
- google-cloud-platform - 我可以为多区域 GKE 集群配置 Google 全局负载均衡器吗