Where to put autonomous django scripts without breaking import?

I'm still pretty new to Python.

I have a Django website with several applications and /libs. I need to add a couple of cron jobs that will use my Django models. I've already done all this, no matter.

I have a problem with my import.

I would like to include these scripts in the application to which they usually belong. But when I execute the script from the command line, it cannot load modules from the directory /libs.

To illustrate, in particular, the structure of dir, imagine this pseudocode:

import ./../libs/mysharedlib.py   

In other words, scripts and sharedlib:

~/project/myapp/myscript.py

~/project/libs/mysharedlib.py

I get what I could just add ~/projectto mine PYTHONPATH, but then I need to worry about it during deployment, and it just feels broken.

~/project? ?

+5
1

, . https://docs.djangoproject.com/en/dev/howto/custom-management-commands/

. cron . , django.

, libs __init__.py? lib ? cron? .

+11

All Articles