Reputation: 2720
I have two django apps and I've called a view of app1 in app2, like this:
#app: app1
#someview.py
def a_view(request, someparam):
#some code here
#app: app2
#otherview.py
from app1.someview import a_view
def another_view(request):
param = 1
a_view(request, param)
def view2(request):
#some code
It works fine. My problem is that now I want to call a view from app2 in app1. So I add the import statement in someview.py like this:
#app: app1
#someview.py
from app2.otherview import view2
def a_view(request, someparam):
#some code here
The result is an ImportError "cannot import name view2". Can anyone tell me why this happen?
Upvotes: 3
Views: 5238
Reputation: 1
You can't do this because makes a loop. You must add functions in another file and import in app1 and app2 separately.
Upvotes: -1
Reputation: 10315
The second import shadowing the first one ... Try like
import app2.otherview
or
from app2.views as app2_views
Upvotes: 2