Skip to content

Commit

Permalink
Streamline migration to use existing record instead of deleting and c…
Browse files Browse the repository at this point in the history
…reating
  • Loading branch information
ramram-mf committed Sep 11, 2024
1 parent c0bb6ae commit 6764b6a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,16 @@ def update_focus_areas_and_add_hero_bottom(apps, schema_editor):
},
]

FocusArea.objects.all().delete()
for area in focus_areas:
FocusArea.objects.create(**area)
existing_focus_areas = list(FocusArea.objects.all())

for index, data in enumerate(focus_areas):
if index < len(existing_focus_areas):
focus_area = existing_focus_areas[index]
focus_area.name = data['name']
focus_area.description = data['description']
focus_area.save()
else:
FocusArea.objects.create(**data)

# Add hero_bottom data to Homepage
homepage = Homepage.objects.first()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% image area.interest_icon width-100 class="tw-max-w-[4em] tw-max-h-[4em]" alt=area.interest_icon.title %}

<div class="tw-text-center medium:tw-text-left">
<h2 class="tw-font-zilla tw-text-[40px]">{{ area.name }}</h2>
<h2 class="tw-font-zilla tw-text-[40px] tw-mb-0">{{ area.name }}</h2>
<p>{{ area.description }}</p>
</div>
</div>
Expand Down

0 comments on commit 6764b6a

Please sign in to comment.