How can I perform Django's `syncdb --noinput` with call_command? -


  & gt; & gt; & gt; Django.core.management आयात से call_command & gt; & gt; & gt; Call_command ('syncdb')   

एक अजगर स्क्रिप्ट के भीतर से syncDB प्रबंधन कमांड निष्पादित करता है हालांकि, मैं एक अजगर खोल या स्क्रिप्ट के भीतर से

  $ python manage.py syncdb --noinput   

के बराबर को चलाने के लिए चाहता हूं। मैं ऐसा कैसे कर सकता हूं?

निम्नलिखित पंक्तियाँ मुझे बिना किसी दखल के सवाल के साथ काम करती हैं कि मैं एक सुपर उपयोगकर्ता बनाना चाहता हूं।

  & gt; & gt; & gt ; Call_command ('syncdb', noinput = true) # इनपुट के लिए पूछता है & gt; & gt; & gt;   

मैं डीजांगो 1.3 का उपयोग करता हूं।

आदेश

संपादित करें:

मुझे स्रोत कोड में जवाब मिला । सभी प्रबंधन कमांड के स्रोत कोड को प्रबंधन / कमांड / (कमांड_नाम) .पी

नामक अजगर मॉड्यूल में पाई जा सकता है। अजगर मॉड्यूल जहां syncdb django.core.management.commands.syncdb

कमांड के स्रोत कोड को खोजने के लिए आप ऐसा कुछ कर सकते हैं:

 < कोड> (env) $ ./manage.py खोल & gt; & gt; & gt; Django.core.management.com से आयात syncdb & gt; & gt; & gt; Syncdb .__ file__ '/home/user/env/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.pyc' & gt; & gt; & gt;   

बेशक, syncdb.py की सामग्री की जांच करें, और syncdb.pyc न करें।

या देख, syncdb.py स्क्रिप्ट में शामिल हैं:

  make_option ('- noinput', एक्शन = 'store_false', dest = 'interactive', default = true, help = 'डीजेंगो को इनपुट के लिए उपयोगकर्ता को संकेत नहीं करने के लिए कहता है किसी भी तरह का। '),   

यह हमें बताता है कि कमांड लाइन पर - noinput के बजाय हमें interactive का उपयोग करना चाहिए अगर हम call_command फ़ंक्शन के साथ कमांड को स्वचालित करना चाहते हैं।

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

ruby on rails - Convert a Activerecord result with has_one associations into a single hash per record -

javascript - Read complete data from stream from onMessage -