以编程方式同步Django中的数据库

Att*_* O. 12 python django django-admin

我正在尝试从视图中同步我的数据库,如下所示:

from django import http
from django.core import management

def syncdb(request):
    management.call_command('syncdb')
    return http.HttpResponse('Database synced.')
Run Code Online (Sandbox Code Playgroud)

问题是,它将通过询问终端的用户输入来阻止开发服务器.如何通过它'--noinput'来防止问我什么?

我有其他方法将用户标记为超级用户,因此不需要用户输入,但我真的需要以编程方式调用syncdb(和flush),而无需通过ssh登录到服务器.任何帮助表示赞赏.

Dav*_*cic 20

management.call_command('syncdb', interactive=False)
Run Code Online (Sandbox Code Playgroud)