[Django]-How to render file in views.py from a different directory?

4👍

You should add somedirectory into TEMPLATE_DIRS tuple defined in settings.py:

settings.py

TEMPLATE_DIRS = (
    ...
    '/path/to/somedirectory'
)

Then you can render it via render() in views.py:

views.py

def foo2(request):
    return render(request, 'myFile2.html', {'user': request.user}) 

Leave a comment