I have several applications in my django project. I would like to re-use some of the functions across all of my apps. I created a new app, and added a custom functions.py to it. Trying the following:
from myNewApp import *
from myNewApp import functions
I get NameError: global name xxx is undefined
Am I omitting something important?
How would you recommend I solve the problem of re-using code across multiple apps?
Thanks,
Imagine that you have a project called commons where you store all the code you want to share. And then you want to use the code of commons in a project called foo. Imagine that you have the follow directories:
The commons.py have this content:
If you want to be able to import the module commons in your file test.py put in this file:
And it will print “Hello world!”.