I have a bunch of files containing python functions, used in a web-serving apache2, they are all called from PHP as shell scripts just with "python3 'file' 'args'" (without the -m, that is) and return data to PHP via JSON strings, are all debugged since a long time, and work well.
They are all in a single directory, and most of them import other files simply using
from file_with_lower_level_functions import gimme_this_table many imported functions in turn import other ones, and some import chains may be 4 or 5 links long.
Trying to import this into Django is nightmarish. All of my "froms" are replied to by "manage.py check" with "module not found". I did obtain partial success by changing the top level froms above to
from .file_with_lower_level_function import gimme_this_table adding the leading dot. But first, changing the "from"s like that in every single module would make them unworkable in the old situation, and I do not want to do this change.
And, next, this gives problems with 2nd links, when one of my functions imports another one: applying the same cure to the 2nd one doesn't work: "Huh uh! module not found"
Is this kind of approach even possible with Django? Is there a common form which would give me a code usable in BOTH django and PHP?
I thought of playing to Django the same trick I did to PHP, that, is calling my code as a shell script, and that would probably work; but since Django is already python, that does not appeal much to me: I would sweat a job and learn nothing.
I tried calling from django views my old functions, and I was expecting that to work without (many) problems.