Coverage for backend/core/auxiliary/methods/copy_flowsheet/copy_primary_keys.py: 100%

5 statements  

« prev     ^ index     » next       coverage.py v7.10.7, created at 2025-11-06 23:27 +0000

1from .copy_caching import ModelLookupDict 

2 

3def update_primary_keys(model_lookups: ModelLookupDict) -> None: 

4 """ 

5 Update the primary keys of all the models. 

6 We set the normal primary key to None, 

7 so that Django will create a new primary key when we save the model. 

8 """ 

9 for Model_Type, models in model_lookups.items(): 

10 for model in models: 

11 # Remove the primary key to create a new one. 

12 model.pk = None