Django和余烬

2024-09-26 18:09:03 发布

您现在位置:Python中文网/ 问答频道 /正文

好吧,所以我想把Django和余烬使用django rest框架和ember-data-django-rest-adapter。我正在使用的应用程序是中提供的todomvc example余烬文档。在

ember应用程序当前正在访问服务器并获得响应(200),但是页面上没有加载任何内容。在

以下是django服务器的响应:

[02/Mar/2014 13:51:09] "GET /todos/?_=1393789869335 HTTP/1.1" 200 177

以下是curl响应的内容(注意:此响应相当于对“localhost/todos/”的请求):

^{pr2}$

适配器的文档声明“适配器假定每个django模型有2个不同的端点。”第二个如下所示,允许单个“todo”的请求:

$> curl -H 'Accept: application/json; indent=4' http:/localhost:8080/todos/1/
{
    "title": "hmm why isnt this working now", 
    "isCompleted": false
}

我认为问题出在我的应用程序.js公司名称:

window.Todos = Ember.Application.create();

Todos.ApplicationAdapter = DS.DjangoRESTAdapter.extend({
  host: 'http://localhost:8080'
 });

 Todos.ApplicationSerializer = DS.DjangoRESTSerializer.extend();

如果任何人有任何想法,任何帮助将不胜感激!如果需要,我可以发布更多代码。谢谢各位。在

编辑:调试。“请求的资源上不存在“Access Control Allow Origin”标头。Origin'null'因此不允许访问。”另一个线程让我相信CORS可能能够解决这个问题。我回来报告。在


Tags: django文档服务器rest应用程序localhosthttp内容

热门问题