gpt4 book ai didi

html - 如何避免 "The number of GET/POST parameters exceeded"错误?

转载 作者:太空狗 更新时间:2023-10-29 13:47:13 24 4
gpt4 key购买 nike

我在我的 Django 网站上创建了一个自定义管理页面,只有管理员可以在其中更改对象及其属性。对象的数量很多(正好 9220 个),在管理页面上,输入字段的数量与该模型中的对象数量相同。

这是代码:

<form action="{% url 'Home:AdminPrices' %}" id="mainForm" method="post">
{% csrf_token %}
{% for item in prices %}
<ul class="row" style="width: 100%;padding: 0;background-color: white;height: 100px;display: flex;justify-content: left;white-space: nowrap;margin-bottom: 0;margin-top: 0;">
<div style="width: 33.333333333333336%;background-color: white;display: block;color: black;font-size: 0.8em;white-space: nowrap;text-align: center;font-family: 'Lato';padding-top: 25px;">{{ item.hashname }}</div>
<div style="width: 33.333333333333336%;background-color: white;display: block;color: black;font-size: 1.2em;text-align: center;font-family: 'Lato';padding-top: 25px;">{{ item.sug }}</div>
<div style="width: 33.333333333333336%;background-color: white;display: block;color: black;font-size: 1.2em;text-align: center;font-family: 'Lato';"><input type="number" value="{{ item.actual }}" name="prices_{{ item.actual }}" style="width: 100%;height: 100%;padding-bottom: 25px;background-color: white;border: 0;color: black;font-size: 1.2em;text-align: center;font-family: 'Lato';"></input></div>
</ul>
{% endfor %}
<input type="submit" id="mainSubmit" style="display: none;" name="submitPrices"></input>
</form>
<div onclick="document.getElementById('mainForm').submit();" style="background-color: black;border-radius: 5px;position: fixed;display: block;height: 50px;width: 200px;bottom: 0;left:0;right:0;margin: 0 auto;color: white;font-size: 1.5em;text-align: center;padding-top: 12.5px;cursor: pointer;">Submit</div>

按下提交按钮后,网站崩溃并提示此错误:

2017-06-25 10:05:53,158: The number of GET/POST parameters exceeded settings.DATA_UPLOAD_MAX_NUMBER_FIELDS. 2017-06-25 10:05:53,860: Error running WSGI application 2017-06-25 10:05:53,934: TooManyFieldsSent: The number of GET/POST parameters exceeded settings.DATA_UPLOAD_MAX_NUMBER_FIELDS. 2017-06-25 10:05:53,934:
File "/home/MTonskins/Tonskins/Selement/senv/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 170, in call 2017-06-25 10:05:53,935: response = self.get_response(request) 2017-06-25 10:05:53,935: 2017-06-25 10:05:53,935: File "/home/MTonskins/Tonskins/Selement/senv/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 124, in get_response 2017-06-25 10:05:53,935: response = self._middleware_chain(request) 2017-06-25 10:05:53,936: 2017-06-25 10:05:53,936: File "/home/MTonskins/Tonskins/Selement/senv/local/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner 2017-06-25 10:05:53,936: response = response_for_exception(request, exc) 2017-06-25 10:05:53,936: 2017-06-25 10:05:53,936: File "/home/MTonskins/Tonskins/Selement/senv/local/lib/python2.7/site-packages/django/core/handlers/exception.py", line 76, in response_for_exception 2017-06-25 10:05:53,937:
response = debug.technical_500_response(request, *sys.exc_info(), status_code=400) 2017-06-25 10:05:53,937: 2017-06-25 10:05:53,937:
File "/home/MTonskins/Tonskins/Selement/senv/local/lib/python2.7/site-packages/django/views/debug.py", line 84, in technical_500_response 2017-06-25 10:05:53,937: html = reporter.get_traceback_html() 2017-06-25 10:05:53,937: 2017-06-25 10:05:53,937: File "/home/MTonskins/Tonskins/Selement/senv/local/lib/python2.7/site-packages/django/views/debug.py", line 316, in get_traceback_html 2017-06-25 10:05:53,938: c = Context(self.get_traceback_data(), use_l10n=False) 2017-06-25 10:05:53,938: 2017-06-25 10:05:53,938: File "/home/MTonskins/Tonskins/Selement/senv/local/lib/python2.7/site-packages/django/views/debug.py", line 293, in get_traceback_data 2017-06-25 10:05:53,938:
'filtered_POST': self.filter.get_post_parameters(self.request), 2017-06-25 10:05:53,938: 2017-06-25 10:05:53,938: File "/home/MTonskins/Tonskins/Selement/senv/local/lib/python2.7/site-packages/django/views/debug.py", line 167, in get_post_parameters 2017-06-25 10:05:53,938: return request.POST 2017-06-25 10:05:53,938: 2017-06-25 10:05:53,939: File "/home/MTonskins/Tonskins/Selement/senv/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 128, in _get_post 2017-06-25 10:05:53,939:
self._load_post_and_files() 2017-06-25 10:05:53,939: 2017-06-25 10:05:53,939: File "/home/MTonskins/Tonskins/Selement/senv/local/lib/python2.7/site-packages/django/http/request.py", line 311, in _load_post_and_files 2017-06-25 10:05:53,939:
self._post, self._files = QueryDict(self.body, encoding=self._encoding), MultiValueDict() 2017-06-25 10:05:53,939: 2017-06-25 10:05:53,940: File "/home/MTonskins/Tonskins/Selement/senv/local/lib/python2.7/site-packages/django/http/request.py", line 397, in init 2017-06-25 10:05:53,940: for key, value in limited_parse_qsl(query_string, **parse_qsl_kwargs): 2017-06-25 10:05:53,940: 2017-06-25 10:05:53,940: File "/home/MTonskins/Tonskins/Selement/senv/local/lib/python2.7/site-packages/django/utils/http.py", line 350, in limited_parse_qsl 2017-06-25 10:05:53,940: 'The number of GET/POST parameters exceeded

我不太确定如何避免它,我可以更改设置并专门为此 View 设置不同的限制吗?或者我可以将所有这些字段作为一个列表提交吗?如果没有,那么解决方案是什么?我可以为特定 View 指定 DATA_UPLOAD_MAX_NUMBER_FIELDS 设置吗?提前致谢。

最佳答案

Django 的文档声明除了设置以外的任何地方都不应更改设置:

https://docs.djangoproject.com/en/1.11/topics/settings/#altering-settings-at-runtime

如您所述,解决方案是增加设置中 DATA_UPLOAD_MAX_NUMBER_FIELDS 的大小。祝你好运!

关于html - 如何避免 "The number of GET/POST parameters exceeded"错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44745355/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com