【问题标题】:Django Ajax post failed with Gunicorn and Nginx on AWSDjango Ajax 帖子在 AWS 上使用 Gunicorn 和 Nginx 失败
【发布时间】:2018-08-24 21:12:18
【问题描述】:

我正在使用由 gunicorn 和 nginx 在 AWS 上部署的 AJAX 编写应用程序。 当我使用python3 manage.py runserver 时效果很好。但是在我使用 gunicorn 之后,AJAX 帖子不起作用。我得到一个Failed to load resource: the server responded with a status of 404 (Not Found)。

我做的是一个非常简单的 AJAX 帖子

$.ajax({
                type: 'POST',
                url: '/analytical-tools/getData/',
                data: {
                  'somedata':somedata
                  csrfmiddlewaretoken: '{{ csrf_token }}'
                },
                dataType: 'json',
                success: function (data) {
                   /*do something*/
                }
});

首先我想问一下,在 Gunicorn 上部署 AJAX 有什么不同吗? 我想问一下如何在gunicorn上调试。 gunicorn 在后台运行,运行时我看不到任何调试信息或打印内容。

【问题讨论】:

    标签: ajax django amazon-web-services nginx gunicorn


    【解决方案1】:

    404 代表未找到...这里的问题是 django 端点完全可用还是不适用于某些数据?

    1) 如果配置 nginx/gunicorn 有问题

    2) 如果对于某些数据,请确保该数据确实存在

    3) 想法确保 JS 中没有废话,例如查看 XHR 部分并复制请求负载,并在 Postman 中交叉验证

    关于调试,日志中应该有每个请求等的文件。

    uwsgi在哪里? https://www.digitalocean.com/community/questions/where-s-my-django-application-log-file

    哪里有 nginx? Where can I find the error logs of nginx, using fastcgi and django

    【讨论】:

      猜你喜欢
      • 2015-04-25
      • 2016-11-18
      • 1970-01-01
      • 2016-08-11
      • 2020-12-29
      • 1970-01-01
      • 1970-01-01
      • 2011-12-31
      • 2018-02-16
      相关资源
      最近更新 更多