Javascript Can';t从Django项目中的角度管线加载模板

Javascript Can';t从Django项目中的角度管线加载模板,javascript,python,angularjs,django,Javascript,Python,Angularjs,Django,在我的url.py中,我有以下模式: url(r'^$', views.index, name='index'), url(r'^setup/$', views.index, name='index'), 这两种模式最终解析为相同的视图,因为逻辑在控制器中处理。视图有点像这样: def index(request): return request(request, 'index.html', {}) .when('/', { controller : 'BaseControl

在我的url.py中,我有以下模式:

url(r'^$', views.index, name='index'),
url(r'^setup/$', views.index, name='index'),
这两种模式最终解析为相同的视图,因为逻辑在控制器中处理。视图有点像这样:

def index(request):
    return request(request, 'index.html', {})
.when('/', {
    controller : 'BaseController',
    templateUrl : 'static/app_partials/base.html',
    reloadOnSearch: false
})
.when('/products/', {
    controller : 'ProductsController',
    templateUrl : 'static/app_partials/products.html',
    reloadOnSearch: false
})
在我的index.html文件中,我加载Angular、Angular应用程序、路线和其他所有内容

我的角度路线如下所示:

def index(request):
    return request(request, 'index.html', {})
.when('/', {
    controller : 'BaseController',
    templateUrl : 'static/app_partials/base.html',
    reloadOnSearch: false
})
.when('/products/', {
    controller : 'ProductsController',
    templateUrl : 'static/app_partials/products.html',
    reloadOnSearch: false
})
现在,当我转到模式中的第一个URL时,一切都很好,路由能够完美地加载模板,因为URL是
http://example.com/static/app_partials/base.html
,这正是文件所在的位置

但是,第二个URL不起作用,因为现在调用的模板是
http://example.com/setup/static/app_partials/base.html
,它不存在

如何解决此问题?我试图将整个URL放在我的路由中,包括域和其他内容,但随后我得到了一个不安全的URL错误。有什么帮助吗?谢谢。

使用绝对URL(带前导斜杠)而不是相对URL


例如,使用
/static/app\u partials/base.html
而不是
static/app\u partials/base.html

您可以使用绝对URL,例如
/static/app\u partials/base.html
而不是像
static/app\u partials/base.html
这样的相对URL来解决问题。非常感谢你。