migrate categories to a multiselect
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.0.2 on 2024-02-26 11:24
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('rcr', '0019_alter_item_oncology_category_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='item',
|
||||
name='radiology_categories',
|
||||
field=models.ManyToManyField(blank=True, related_name='items_radiology', to='rcr.radiologycategory'),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,21 @@
|
||||
# Generated by Django 5.0.2 on 2024-02-26 11:40
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
def move_radiology_categories(apps, schema_editor):
|
||||
Item = apps.get_model("rcr", "Item")
|
||||
#RadiologyCategory = apps.get_model("rcr", "RadiologyCategory")
|
||||
for item in Item.objects.all():
|
||||
if item.radiology_category:
|
||||
item.radiology_categories.add(item.radiology_category)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('rcr', '0020_item_radiology_categories'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(move_radiology_categories),
|
||||
]
|
||||
Reference in New Issue
Block a user