TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

AJAX and Django Views

63 点作者 kennethlove大约 13 年前

2 条评论

toumhi大约 13 年前
Very good article. Using AJAX with Django always feels a bit unnatural, as there's no standard way to do it and everyone has its own way of dealing with it, so it's interesting to see how others do it (in particular utility functions). I think there are also django packages that provide an AJAXy layer (but never used it).<p>It's already hinted at in the blog post, but for writing clean apps using AJAX a lot, django-tastypie and backbone.js really do work well together (I've just started using them in combination in my latest toy project).
评论 #3711097 未加载
H_E_Pennypacker大约 13 年前
That bit of CSRF javascript does not "ignore" CSRF checking, and is not unsafe. The only difference is that it sets the CSRF token value as a request header rather than a POST value. The browser still needs to have that CSRF cookie value.<p>Edit: Code backing from middleware/csrf.py:<p>request_csrf_token = request.POST.get('csrfmiddlewaretoken', '') if request_csrf_token == "": # Fall back to X-CSRFToken, to make things easier for AJAX request_csrf_token = request.META.get('HTTP_X_CSRFTOKEN', '')
评论 #3711747 未加载