# api/management/commands/seed.py from django.core.management.base import BaseCommand from api.models import Atoll, Island class Command(BaseCommand): help = "Seeds baseline reference data (atolls and islands) required for sign up." def handle(self, *args, **options): # Atoll name must match the person-verify API's `atoll_en` (the atoll # code letter, e.g. "F" for Faafu) or user verification fails. atoll, atoll_created = Atoll.objects.get_or_create(name="F") self.stdout.write( self.style.SUCCESS(f"Created atoll: {atoll.name}") if atoll_created else self.style.NOTICE(f"Atoll already exists: {atoll.name}") ) island, island_created = Island.objects.get_or_create( name="Dharanboodhoo", defaults={"atoll": atoll} ) self.stdout.write( self.style.SUCCESS(f"Created island: {island.name} ({atoll.name})") if island_created else self.style.NOTICE(f"Island already exists: {island.name}") ) self.stdout.write(self.style.SUCCESS("Seeding complete."))