English 中文(简体)
• 道路问题
原标题:Running Django Custom Management Command - Path Issues

我不理解为什么没有找到指挥:

khandelwal@simba:/opt/code/cdcschool$ python schoolcommand/manage.py createcampaign
Unknown command:  createcampaign 
Type  manage.py help  for usage.

When this works fine:

khandelwal@simba:/opt/code/cdcschool$ cd schoolcommand/
khandelwal@simba:/opt/code/cdcschool/schoolcommand$ python manage.py createcampaign
Error: Provide: <type start_date end_date>

这是我的指挥所所在地:

$ ls schoolcommand/management/
commands  __init__.py  __init__.pyc

$ ls schoolcommand/management/commands/
campaignmanager.py   createcampaign.py   __init__.py
campaignmanager.pyc  createcampaign.pyc  __init__.pyc

我如何确定,以便我能够做到:

khandelwal@simba:/opt/code/cdcschool$ python schoolcommand/manage.py createcampaign

我的PYTHONPATH, DJANGO_SETMENTS_MODULE 而我的情况就是如此。 奶粉位于何处。

khandelwal@simba:/opt/code/cdcschool$ ls
Procfile  README  requirements.txt  schoolcommand
khandelwal@simba:/opt/code/cdcschool$ echo $PYTHONPATH

khandelwal@simba:/opt/code/cdcschool$ echo $DJANGO_SETTINGS_MODULE

khandelwal@simba:/opt/code/cdcschool$ find . -name settings.py
./schoolcommand/settings.py
khandelwal@simba:/opt/code/cdcschool$
问题回答

当你使用Django时,有两项重要规则。

首先。

You have a settings.py file which must be used by the web server and all the manage.py commands. All of them.

The default place to look for the settings.py file is the current working directory. You can change this with the PYTHONPATH and the DJANGO_SETTINGS_MODULE environment variable.

The manage.py is created for you in the same directory as the settings.py.

页: 1 如果您不想使用<代码>manage.py。

第二。

<代码>manage.py 指挥机关对他们没有任何“平静”。 他们只是一句话的指挥,不管他们生活在你的申请树里。

页: 1

http://www.un.org。

cd /path/to/your/settings
python manage.py createcampaign

如果贵国的环境有<条码>编码/校正/编码>,这意味着贵网站和所有你的指挥都将在该名录内运作。





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签