Programmatically sync the db in Django

前端 未结 2 454
半阙折子戏
半阙折子戏 2021-02-07 21:10

I\'m trying to sync my db from a view, something like this:

from django import http
from django.core import management

def syncdb(request):
    management.call_         


        
相关标签:
2条回答
  • 2021-02-07 21:59
    management.call_command('syncdb', interactive=False)
    
    0 讨论(0)
  • 2021-02-07 22:03

    Works like this (at least with Django 1.1.):

    from django.core.management.commands import syncdb
    syncdb.Command().execute(noinput=True)
    
    0 讨论(0)
提交回复
热议问题