Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
Is it possible to call function located in api.py file from models.py?
api.py
models.py
If so, what should be done to achieve the result?
You can use:
from my_app.api import my_function
Add a comment
Yes you can do that easily depending on the location of api.py file.
1. At Same Level:
from api import desired_function
You can even use relative imports.
from .api import desired_function
2. In a different app:
from some_app.api import desired_function
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.