lty/qy_lty/card/management/commands/create_example_cards.py
2026-03-17 13:17:02 +08:00

22 lines
917 B
Python

from django.core.management.base import BaseCommand, CommandError
from card.example_data import create_examples
class Command(BaseCommand):
help = '创建示例卡牌数据,包含所有类型的卡牌'
def handle(self, *args, **options):
self.stdout.write(self.style.NOTICE('正在创建卡牌示例数据...'))
try:
results = create_examples()
# Print summary
self.stdout.write(self.style.SUCCESS('成功创建以下卡牌模板:'))
for category, templates in results.items():
self.stdout.write(f" - {category}: {', '.join([t.name for t in templates])}")
self.stdout.write(self.style.SUCCESS('示例卡牌数据创建完成!'))
except Exception as e:
raise CommandError(f'创建卡牌示例数据时出错: {str(e)}')