我正在試圖通過Django中的{%include%}獲取包含頁面的.html頁面的POST值。但是,它僅從最初的html頁面返回POST。在包含在Django中的.html頁面的POST中獲取
中包括我在內的HTML具有的代碼片段:
div id="edit_parameters"><a href="#{{job.slug}}" data-toggle="collapse">Edit Parameters</a></div>
<div data-id="{{job.slug}}" id="{{job.slug}}" class="collapse">
<form class = "form-inline" method="post">
{% csrf_token %}
{% for parameter in job.get_object.parameters %}
<p>
<input type="text" class="input-small" name="{{parameter}}" value="" id ="{{parameter}}-input" placeholder="{{parameter}}">
</p>
{% endfor %}
<button type="submit" class="btn btn-primary run-job">Submit</button>
</form>
</div>
{% else %}
<div>
No editable parameters for this job.
</div>
{% endif %}
我的外部HTML文件中有一個片段:
<ul id="available-jobs">
{% if jobs_same_io_type and jobs_diff_io_type %}<h3> Current Step </h3>
{% elif jobs_same_io_type %} <h3> Next Step </h3> {% endif %}
{% for job in jobs_same_io_type %}
{% include "includes/job_li.html" with add=1 %}
{% endfor %}
{% if jobs_diff_io_type %} <h3> Next Step </h3> {% endif %}
{% for job in jobs_diff_io_type %}
{% include "includes/job_li.html" with add=1 %}
{% endfor %}
{% if not jobs_same_io_type and not jobs_diff_io_type %}
<li class="full-height">There are no more available jobs.</li>
{% endif %}
</ul>
<fieldset class="submit">
{% csrf_token %}
<input type="hidden" name="job_to_run" value="" id="job-to-run" />
<input type="hidden" name="workflow_jobs" value="" id="ordered-jobs" />
<input type="hidden" name="job_to_edit" value="" id="job-to-edit" />
<input type="hidden" name="job_to_add" value="" id="job-to-add" />
<input type="hidden" name="job_to_remove" value="" id="job-to-remove" />
<input type="submit" name="done" value="I'm done, start the jobs" id="jobs-ready" />
</fieldset>
,顯示在後的一切都在的投入第二個片段。但是當我爲所有POST值使用request.POST時,我不想包含第一個片段所需的參數。
任何幫助將不勝感激解釋爲什麼我沒有從包含的頁面獲取值並找到可能的解決方案。謝謝!
HTTP只允許一個帖子。看起來你想立即張貼幾個表格? – RParadox
有沒有辦法從一組特定的「參數」或特定的表單中獲取POST? – user992296