Skip to content

Commit

Permalink
change for loop to use enumerate instead of list.index(item)
Browse files Browse the repository at this point in the history
  • Loading branch information
sindrelothe committed Sep 7, 2023
1 parent 02d567a commit 848cdb9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions backend/root/management/commands/seed_scripts/textitems.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def seed():
TextItem.objects.all().delete()
yield 0, 'Deleted old textitems'

for item in text_items:
for i, item in enumerate(text_items):
text_item, created = TextItem.objects.get_or_create(key=item['key'], text_nb=item['text_nb'], text_en=item['text_en'])
if created:
yield (100 * (text_items.index(item) + 1) // len(text_items), f'Created {len(TextItem.objects.all())} textitems')
yield (100 * (i + 1) // len(text_items), f'Created {len(TextItem.objects.all())} textitems')

0 comments on commit 848cdb9

Please sign in to comment.