javascript - Django有没有类似now.js的框架?

标签 javascript ajax django nowjs-sockets

<分区>

我正在寻找一个框架,它可以让我只更新结构中的数据,而不用每次都处理查询和 View 。

我知道,使用 Node 和 express 会更好,但我已经尝试过,并且觉得我可以更好地利用 Django。

最佳答案

我知道这个话题已经很老了,但还是要回答一下:

我发现了这个:

http://dajaxproject.com/

网站示例:

ajax.py

from django.utils import simplejson
from dajaxice.decorators import dajaxice_register

@dajaxice_register
def dajaxice_example(request):
    return simplejson.dumps({'message':'Hello from Python!'})

html

<input type="button" name="rand" value="Get message from server!" id="rand" onclick="Dajaxice.examples.dajaxice_example(my_callback)">

JavaScript

function my_callback(data){
    alert(data.message);
}

我无法让它与“生产标准”一起工作......

now.js 的真正魔力还在于你在两边都有 JS,因此没有要转换/(un)序列化的对象

我在考虑这样的设置:

DJANGO <-> NODEJS <-> 现在 <-> 浏览器

Django 可以将序列化为 json 的对象发送到节点,节点将完成剩下的工作......

我想这会有点棘手……我也考虑过换个方向:意思是获得所有 django 的好特性(模型、(自动)admin、模板、url、中间件……)

我找不到像 django (contrib) admin 一样好的东西!!有谁知道吗?

关于javascript - Django有没有类似now.js的框架?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7112561/

相关文章:

python - Django,使用 nGinx 提供静态文件给出错误 404

python - 通过给 django 提供 url 无法打开页面

python - django mysql 给出页面未找到(404)而 sqlite 工作正常

javascript - 包含对象数组的 typescript 文字对象

javascript - 如何使用 javascript/jquery 查找和替换 html 字符串中的开始标记和结束标记

ajax - 让 jQuery TipTip 能够处理 ajax 加载的内容

python - 如何在python 3中获取该站点中的json数据?

javascript - 为什么单击 div 时 document.execCommand 不起作用?

javascript - 使用 JQuery 根据 bootstrap-3-typeahead 下拉列表将值传递给多个动态创建的控件

ajax - 包含文件的 Jquery ajax 表单提交