From 65a950a28a743a4987b7555234be8b26dbf30801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Sun, 2 Aug 2020 18:29:10 +0800 Subject: [PATCH] Changed the safe-guard condition of the accounting_sample command in the accounting application. --- accounting/management/commands/accounting_sample.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/accounting/management/commands/accounting_sample.py b/accounting/management/commands/accounting_sample.py index a882f62..019ec57 100644 --- a/accounting/management/commands/accounting_sample.py +++ b/accounting/management/commands/accounting_sample.py @@ -19,6 +19,7 @@ """ import random +import sys from django.core.management import BaseCommand, CommandParser from django.db import transaction @@ -47,8 +48,9 @@ class Command(BaseCommand): *args (list[str]): The command line arguments. **options (dict[str,str]): The command line switches. """ - print("This may mess up your data. Continue? [Y/N] ", end="") - if input().lower() not in ("y", "yes"): + if User.objects.first() is not None: + print("Refused to fill in sample data with existing data.", + file=sys.stderr) return with transaction.atomic():