Reputation: 87
I have 2 index.html files in django project, but in different apps. How can i show direct separately for each of them?
def index(request):
return render(request, 'index.html')
Upvotes: 0
Views: 141
Reputation: 1928
create the following folder structure
- app1
-- templates
--- app1
---- index.html
- app2
-- templates
--- app2
---- index.html
then in your views.py for app1
def index(request):
return render(request, 'app1/index.html')
That folderstructure is called namespacing. Read here the section "Template namespacing"
Upvotes: 2