首页 > 解决方案 > 如何在 django 应用程序中调用 collectstatic 例程?

问题描述

我的 Django 应用程序使用 css/html 主题,我可以从用户界面上传新主题,也就是说,普通用户可以上传新主题而无需 IT 人员。我通常调用 os.run('python manage.py collectstatic') 但我想知道是否有可能以更优雅或 Pythonic 的方式进行。

标签: djangocollectstatic

解决方案


您可以使用call_command(...)--(doc)作为,

from django.core import management

management.call_command("collectstatic")

推荐阅读