简体   繁体   English

带有 Apache 的 django-rest-framework-datatables 显示 414 URI 太长错误

[英]django-rest-framework-datatables with Apache shows 414 URI too long error

Pre-requisites先决条件

  • OS - Centos 7操作系统 - Centos 7
  • Python 3.6.4 Python 3.6.4
  • Django 3.0 (or 3.1.1) Django 3.0(或 3.1.1)
  • Django Rest framework 3.11.1 Django Rest 框架3.11.1
  • django-rest-framework-datatables 0.5.0 django-rest-framework-datatables 0.5.0
  • Apache 2.4 Apache 2.4
  • ORACLE 19.1 ORACLE 19.1

I have a simple Rest API - which fetches all data from a table in Oracle database.我有一个简单的 Rest API - 它从 Oracle 数据库中的表中获取所有数据。 This Django Framework is hosted on Apache webserver.这个 Django 框架托管在 Apache 网络服务器上。 This data is fed into a datatable using the django-rest-framework-datatables.使用 django-rest-framework-datatables 将该数据输入到数据表中。

  • When I fetch data from the API using djangorest framework it works well.当我使用 djangorest 框架从 API 获取数据时,它运行良好。
  • When I fetch data using the template with ?format=datatables as the query parameter the URL is changed and it becomes a very long URL since my table consists of 50-60 columns.当我使用带有?format=datatables作为查询参数的模板获取数据时,URL 发生了变化,它变成了一个很长的 URL,因为我的表包含 50-60 列。
  • Thus throws a 414 error.因此抛出 414 错误。

Did anybody else face this error?还有其他人遇到这个错误吗?

It works well with the django's inherent webserver but when used using Django fails.它适用于 django 的固有网络服务器,但在使用 Django 时会失败。

Django-rest-framework datatables also support POST requests which solves this particular problem of too long GET URIs, see: Django-rest-framework 数据表还支持 POST 请求,解决了 GET URI 过长的特殊问题,请参阅:

https://django-rest-framework-datatables.readthedocs.io/en/latest/tutorial.html#using-datatables-via-post-method https://django-rest-framework-datatables.readthedocs.io/en/latest/tutorial.html#using-datatables-via-post-method

and:和:

https://datatables.net/examples/server_side/post.html https://datatables.net/examples/server_side/post.html

Yes, I faced such issue and reconfigured the code to shorten the URI.是的,我遇到了这样的问题并重新配置了代码以缩短 URI。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM