分支机构的项目管理,基于Django

This commit is contained in:
2025-11-11 11:09:01 +08:00
commit f0cbf2c2ec
284 changed files with 9472 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
import random
from django.core.management.base import BaseCommand
from huodong.models import Branch
class Command(BaseCommand):
help = '随机修改所有branch实例的背景色'
def handle(self, *args, **kwargs):
colors = ['#f8fafc', '#f1f5f9', '#f9fafb', '#f3f4f6', '#fafafa',
'#f4f4f5', '#fafafa', '#f5f5f5', '#fafaf9', '#f5f5f4',
'#fef2f2', '#fee2e2', '#fff7ed', '#ffedd5', '#fffbeb',
'#fef3c7', '#fefce8', '#fef9c3', '#f7fee7', '#ecfccb',
'#f0fdf4', '#dcfce7', '#ecfdf5', '#d1fae5', '#f0fdfa',
'#ccfbf1', '#ecfeff', '#cffafe', '#f0f9ff', '#e0f2fe',
'#eff6ff', '#dbeafe', '#eef2ff', '#e0e7ff', '#f5f3ff',
'#ede9fe', '#faf5ff', '#f3e8ff', '#fdf4ff', '#fae8ff',
'#fff1f2', '#ffe4e6']
branches = Branch.objects.all()
for branch in branches:
branch.background_color = random.choice(colors)
branch.save()
self.stdout.write(self.style.SUCCESS('已成功修改所有branch实例的背景色'))
# 在终端运行此命令
# python manage.py your_command_name