-
Ernesto Rico Schmidt authoredErnesto Rico Schmidt authored
loadfixtures.py 527 B
import glob
from django.core.management import BaseCommand, call_command
class Command(BaseCommand):
help = "Loads the fixtures from the directory."
def add_arguments(self, parser):
parser.add_argument("directory", help="Directory with fixtures.", nargs="+", type=str)
def handle(self, *args, **options):
directories = options["directory"]
for directory in directories:
if files := glob.glob(f"fixtures/{directory}/*.json"):
call_command("loaddata", files)