Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion medcat-trainer/webapp/api/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,12 @@ def save(self, *args, skip_load=False, **kwargs):
except Exception as exc:
raise MedCATLoadException(f'Failure loading MetaCAT models - {unpacked_model_pack_path}') from exc

super().save(*args, **kwargs)
if not is_new:
super().save(*args, **kwargs)
else:
# For new objects, just update the FK fields without full save
# Fixes psycopg.errors.UniqueViolation: duplicate key value violates unique constraint "api_modelpack_pkey"
super().save(update_fields=['concept_db', 'vocab'])

def __str__(self):
return self.name
Expand Down