Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to place external python scripts in a Django project?

Where someone should place any external python script for her Django project? What is the more appropriate location (if any)? Shall she create a folder in the main Django project and put it there and add this to the python path or is there a better way to deal with this issue? The reason for external scripts is not to overload the views with code that can be better organized in script files and can serve more than one views.

like image 342
pebox11 Avatar asked Aug 19 '15 03:08

pebox11


1 Answers

Create a folder, say utils, and make it a module by creating __init__.py inside it. Now create any script under this folder. Let's say you have a file called utils.py that contains some of your python code and you want to import it.

Wherever you want to import then import your python script like

from utils.utils import YourClassOrFunction
like image 185
gamer Avatar answered Oct 11 '22 03:10

gamer