问题描述
我在我的Django网站上创建了一个自定义管理页面,其中只有管理员将被允许,并且能够更改对象及其属性。
对象的数量非常多(精确到9220),并且在管理页面上有相同数量的输入字段作为该模型中的对象。
I have created a custom admin page on my Django website, Where only administrators will be allowed and will be able to change objects and their attributes.The amount of objects is a lot (9220 exactly) and on admin page there are equal amounts of input fields as objects in that model.
这是代码:
This is the code:
<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>
按下提交按钮后,网站崩溃并提示出现此错误:
Once submit button is pressed, Website crashes and prompts out this error:
我不太确定我该如何避免它,我可以更改设置并专门为此视图设置不同的限制吗?或者我可以提交所有这些领域作为一个列表?如果不是,那么解决方案是什么?我可以在某些视图中指定 DATA_UPLOAD_MAX_NUMBER_FIELDS
设置吗?
I'm not quite sure how can i avoid it, Could i change the settings and set different limit specifically for this view? Or could i submit all these fields as one list? If not, Then what could be the solution? Can i specify DATA_UPLOAD_MAX_NUMBER_FIELDS
setting to certain view? Thanks in advance.
推荐答案
Django的文档指出,设置不应该在设置以外的任何地方更改:
Django's documentation states that settings shouldn't be changed anywhere other than the settings:
正如您所提到的,是否会增加设置中 DATA_UPLOAD_MAX_NUMBER_FIELDS
的大小。祝你好运!
The solution, as you mentioned, is it increase the size of DATA_UPLOAD_MAX_NUMBER_FIELDS
in the settings. Good luck!
这篇关于如何避免“超过GET / POST参数的数量”错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!