Skip to content

Conversation

@alhendrickson
Copy link
Collaborator

@alhendrickson alhendrickson commented Feb 10, 2026

Error before on model pack save, including using the new Admin form.

[medcattrainer] File "/home/api/api/models.py", line 140, in save  
[medcattrainer] super().save(*args, update_fields=['concept_db', 'vocab'], **kwargs)
[medcattrainer] File "/usr/local/lib/python3.11/site-packages/django/db/models/base.py", line 852, in save 
[medcattrainer] raise ValueError("Cannot force both insert and updating in model saving.")
[medcattrainer] ValueError: Cannot force both insert and updating in model saving.

Fix

Remove force_insert and change to force_update from the kwargs

[medcattrainer] INFO 2026-02-10 14:55:08,117 models.py l:148:ModelPack.save() - Before modification: kwargs={'force_insert': True, 'using': 'default'}, pk=1, _state.adding=False
[medcattrainer] INFO 2026-02-10 14:55:08,117 models.py l:152:ModelPack.save() - Removed force_insert=True from kwargs
[medcattrainer] INFO 2026-02-10 14:55:08,117 models.py l:154:ModelPack.save() - After modification: kwargs={'using': 'default', 'force_update': True}, update_fields=[concept_db, vocab]

@tomolopolis
Copy link
Member

Copy link
Collaborator

@mart-r mart-r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a reasonable fix to me

@alhendrickson alhendrickson merged commit 340284f into main Feb 10, 2026
10 checks passed
@alhendrickson alhendrickson deleted the fix/trainer/modelpack-save branch February 10, 2026 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants