Skip to content

Commit

Permalink
Fix for Django 1.10 loaddata
Browse files Browse the repository at this point in the history
loaddata raises a CommandError instead of showing a warning when the
specified fixture file is not found.
  • Loading branch information
adamchainz authored and timgraham committed Nov 23, 2016
1 parent d6bb6c6 commit 487460d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions djangobench/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,19 @@ def run_benchmark(benchmark, migrate=True, setup=None, trials=None, handle_argv=
if hasattr(django, 'setup'):
django.setup()
if migrate:
from django.core.management import call_command
from django.core.management import CommandError, call_command
if django.VERSION < (1, 7):
call_command("syncdb", run_syncdb=True, verbosity=0)
else:
call_command("migrate", run_syncdb=True, verbosity=0)
if django.VERSION >= (1, 8):
call_command("loaddata", "initial_data", verbosity=0)
try:
call_command("loaddata", "initial_data", verbosity=0)
except CommandError as exc:
# Django 1.10+ raises if the file doesn't exist and not
# all benchmarks have files.
if 'No fixture named' not in str(exc):
raise

if setup:
setup()
Expand Down

0 comments on commit 487460d

Please sign in to comment.