Use filter in Django without directly updating and adding characters (similar to CONCAT in mysql)

1. Using update directly in mysql will update the entire remark field

update basp_role set remark='My remark information' where role_code='role09131606auto';

2. The CONCAT function can be used in mysql to directly add fields to existing fields

update basp_role set remark=CONCAT(remark,'my remark information') where role_code='role09131606auto';

3. In Django, the CONCAT function can also be used

BaspRole.objects.filter(role_id=role_id).update(remark=Concat('remark', Value('my remarks')))

 

Guess you like

Origin blog.csdn.net/bugua3542/article/details/126838921