From 6a47c664c846518505e62a392a3faf37aff9682a Mon Sep 17 00:00:00 2001 From: ngfchl Date: Mon, 19 Sep 2022 19:52:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=8E=B7=E5=8F=96=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E5=99=A8=E5=AF=BC=E8=87=B4=E5=9C=A8=E6=9C=AA=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=95=B0=E6=8D=AE=E5=BA=93=E6=97=B6=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E6=89=A7=E8=A1=8Cmakemigrations=E5=92=8Cmigrate=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pt_site/admin.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pt_site/admin.py b/pt_site/admin.py index 35317ed..0bfc646 100644 --- a/pt_site/admin.py +++ b/pt_site/admin.py @@ -952,6 +952,15 @@ class TorrentInfoAdmin(ImportExportModelAdmin, AjaxAdmin): # instead of ModelAd # # 模拟处理业务耗时 # time.sleep(2) # 可以根据request的用户,来动态设置返回哪些字段,每次点击都会来获取配置显示 + + @staticmethod + def get_downloader(): + """获取下载器列表""" + try: + return [{'key': i.id, 'label': i.name} for i in Downloader.objects.all()] + except Exception as e: + return [] + to_download.layer = { # 弹出层中的输入框配置 # 这里指定对话框的标题 @@ -976,6 +985,6 @@ class TorrentInfoAdmin(ImportExportModelAdmin, AjaxAdmin): # instead of ModelAd # value字段可以指定默认值 'value': '', # 列表推导式来获取下载器 - 'options': [{'key': i.id, 'label': i.name} for i in Downloader.objects.all()] + 'options': get_downloader() }] }