这是一个教育项目,不适用于生产.我不打算将用户登录作为其中的一部分.
我可以使用CSRF令牌对Django进行POST调用而无需用户登录吗?我可以不使用jQuery吗?我在这里超出了我的深度,肯定会混淆一些概念.
对于JavaScript方面,我发现了这个redux-csrf包.我不确定如何将它与我POST使用Axios的动作结合起来:
export const addJob = (title, hourly, tax) => {
console.log("Trying to addJob: ", title, hourly, tax)
return (dispatch) => {
dispatch(requestData("addJob"));
return axios({
method: 'post',
url: "/api/jobs",
data: {
"title": title,
"hourly_rate": hourly,
"tax_rate": tax
},
responseType: 'json'
})
.then((response) => {
dispatch(receiveData(response.data, "addJob"));
})
.catch((response) => {
dispatch(receiveError(response.data, "addJob"));
})
}
};
Run Code Online (Sandbox Code Playgroud)
在Django方面,我已经阅读了关于CSRF的这个文档,这通常与基于类的视图一起使用.
这是我到目前为止的观点:
class JobsHandler(View):
def get(self, request):
with open('./data/jobs.json', 'r') as f:
jobs = json.loads(f.read())
return …Run Code Online (Sandbox Code Playgroud) 当我们在浏览器上看到它时,我们可以增加空间吗?
例如,
Home Away
Run Code Online (Sandbox Code Playgroud)
我希望它在这两个词之间有更大的空间而不是添加太多
或者也许有其他解决方案而不是使用 ?
axios ×1
css ×1
django ×1
django-csrf ×1
git ×1
git-rebase ×1
gitlens ×1
reactjs ×1
redux ×1
whitespace ×1