load_initial_data.py 506 B

1234567891011121314
  1. import os
  2. from django.conf import settings
  3. from django.core.management.base import BaseCommand
  4. from django.core.management import call_command
  5. class Command(BaseCommand):
  6. def handle(self, **options):
  7. fixtures_dir = os.path.join(settings.BASE_DIR, 'base', 'fixtures')
  8. fixture_file = os.path.join(fixtures_dir, 'bakerydemo.json')
  9. call_command('loaddata', fixture_file, verbosity=0)
  10. print("Awesome. Your data is loaded! The bakery's doors are almost ready to open...")