0

This story takes place under Ubuntu linux 10 with python 2.6.5.

I have created a new custom command in my django project call taskserver.

When I am in the project directory (which is /opt/acme/python-site/acme/ and I execute

python manage.py taskserver

the custom command is started correctly.

When I am in /opt/acme/ the following command executes my custom taskserver command:

python /opt/acme/python-site/acme/manage.py taskserver

When I am in /opt/acme/deploy/ the following command (same as above) fails to execute my custom taskserver command:

python /opt/acme/python-site/acme/manage.py taskserver

It complains that:

Unknown command: 'taskserver'  
Type 'manage.py help' for usage.

Any idea why the current location matters even though I am specifying the full path to my manage.py file? I need to get this command running from a fabric script which resides in the deploy directory. Any suggestions on how to make this work?

Krystian Cybulski
  • 10,789
  • 12
  • 67
  • 98
  • Take a lookt to [http://stackoverflow.com/questions/1601153/django-custom-command-and-cron](http://stackoverflow.com/questions/1601153/django-custom-command-and-cron) – dani herrera Jan 11 '12 at 12:56

2 Answers2

2

Make sure the application with the management package is in your PYTHONPATH. Eg, if taskserver.py is in /opt/acme/python-site/acme/management/commands/taskserver.py

env PYTHONPATH=$PYTHONPATH:/opt/acme/python-site/acme python /path/to/manage.py taskserver

In general, specifying the full path to manage.py won't necessarily set up your PYTHONPATH correctly.

Fabric may also have it's own methods of setting the PYTHONPATH environment var, I don't remember offhand. But using env should work regardless.

AdamKG
  • 13,678
  • 3
  • 38
  • 46
0

try this

python ../python-site/acme/manage.py taskserver

when you are in /opt/acme/deploy/ you must go back to previous dir. by ../ then you are in /opt/acme/ dir, here your path to manage.py is ../python-site/acme/manage.py

Ahsan
  • 11,516
  • 12
  • 52
  • 79