分支机构的项目管理,基于Django
This commit is contained in:
0
fzjgact/huodong/management/__init__.py
Normal file
0
fzjgact/huodong/management/__init__.py
Normal file
BIN
fzjgact/huodong/management/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
fzjgact/huodong/management/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
0
fzjgact/huodong/management/commands/__init__.py
Normal file
0
fzjgact/huodong/management/commands/__init__.py
Normal file
Binary file not shown.
Binary file not shown.
0
fzjgact/huodong/management/commands/_private.py.py
Normal file
0
fzjgact/huodong/management/commands/_private.py.py
Normal 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
|
||||
Reference in New Issue
Block a user