From bef18f03902acabf4faac31b9c7b630c5ddb622a Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 21 Oct 2026 00:51:39 +1100 Subject: [PATCH] Tweaks to fixture data setup command (#13047) --- tasks.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tasks.py b/tasks.py index 5507112747..e65148f357 100644 --- a/tasks.py +++ b/tasks.py @@ -1579,8 +1579,14 @@ def delete_data(c, force: bool = False, migrate: bool = False, verbose: bool = F success('Existing data deleted') -@task(post=[rebuild_models, rebuild_thumbnails]) -def import_fixtures(c): +@task( + post=[rebuild_models, rebuild_thumbnails], + help={ + 'clear': 'Clear existing data before importing fixtures', + 'verbose': 'Print verbose output from management commands', + }, +) +def import_fixtures(c, clear: bool = False, verbose: bool = False): """Import fixture data into the database. This command imports all existing test fixture data into the database. @@ -1590,6 +1596,9 @@ def import_fixtures(c): - Running this command may overwrite existing database data!! - Don't say you were not warned... """ + if clear: + delete_data(c, force=True, verbose=verbose) + fixtures = [ # Build model 'build', @@ -1617,7 +1626,7 @@ def import_fixtures(c): command = 'loaddata ' + ' '.join(fixtures) - manage(c, command, pty=True) + manage(c, command, pty=True, verbose=verbose) # Execution tasks