If you have this file in the same directory, you can access it's functions like this:
from .file2 import function
The dot is important, since it clarifies the path to the file
For example: you have defined some foo_form
in your forms.py
and you want to use it in your views.py
, which is in the same directory as forms.py
, your views.py
should look like this:
from .forms import foo_form
def foo(request):
form = foo_form()
If the file you want to import is in different directory though, you may want to check this question: Importing files from different folder