def sub_folder_available(request):
    folder = convert_url_path_to_folder_path(request.path)
if os.access(folder + '/base.html', os.F_OK):
    base = folder + '/base.html'
else:
    base = 'base.html'
Django: specifying a base template by directory