我的项目页面有一个问题。
我有一个页面,用于查找mouvements历史记录: Page url包含用于搜索查询的特定位置的ID 一旦在页面上,用户必须选择开始和结束日期,然后使用这些信息,sql查询在我的视图中获取信息,并且django用结果填充数据表。
我的问题是,一旦用户在模板上选择日期信息,我该如何将日期信息发送回去?
编辑:
这是我的观点:
def historique(request, pk):
silo = pk[:2]
cellule = pk[-2:]
full = pk
""" Connection to server [SRV-APPLIC1\SQL_SUPV] - Database [BD_SITE] """
cnxn = pyodbc.connect("Driver={SQL Server Native Client 11.0};"
"Server=SRV-APPLIC1\SQL_SUPV;"
"Database=BD_SITE;"
"UID=xx;"
"PWD=xxxxxxxx;")
cursor = cnxn.cursor()
"""MS SQL CALL TO STORED PROCEDURE SP_webGET_PBASCULE """
arguments = (full, 'RCP', '01/01/2017','01/12/2017')
cursor.execute("{CALL SP_webGET_HISTO_CELLULE(?,?,?,?)}", arguments)
mouvementRCPs = cursor.fetchall()
arguments = (full, 'PT0', '01/01/2017','01/12/2017')
cursor.execute("{CALL SP_webGET_HISTO_CELLULE(?,?,?,?)}", arguments)
mouvementPT0s = cursor.fetchall()
arguments = (full, 'PT0', '01/01/2017','01/12/2017')
cursor.execute("{CALL SP_webGET_HISTO_CELLULE(?,?,?,?)}", arguments)
mouvementCHGs = cursor.fetchall()
return render(request, 'PageHistos.html', locals())
模板:
{% load static %}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Contrôle commande niveau cellule</title>
<meta name="generator" content="WYSIWYG Web Builder 12 - http://www.wysiwygwebbuilder.com">
<link href="{% static 'css/Gestion_Mouvements.css' %}" rel="stylesheet">
<link href="{% static 'css/PageHistos.css' %}" rel="stylesheet">
<link href="{% static 'css/base/jquery-ui.min.css' %}" media="all" rel="stylesheet">
<link href="{% static 'css/jquery.dataTables.min.css' %}" media="all" rel="stylesheet">
<link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet" media="all">
<link href="{% static 'css//bootstrap-datetimepicker.min.css' %}" media="all" rel="stylesheet">
<script src="{% static 'js/jquery-1.12.4.min.js' %}"></script>
<script src="{% static 'js/jquery.dataTables.min.js' %}"></script>
<script src="{% static 'js/jquery-ui.min.js' %}"></script>
<script src="{% static 'js/bootstrap.min.js' %}"></script>
<script src="{% static 'js/bootstrap-datetimepicker.js' %}"></script>
<script src="{% static 'js/bootstrap-datetimepicker.fr.js' %}"></script>
<script>
$(document).ready(function()
{
var jQTHistoOptions =
{
show: false,
event: 'click',
collapsible: false
};
$("#jQTHisto").tabs(jQTHistoOptions);
});
</script>
<script>
$(document).ready(function() {
$('#entrantTab').dataTable( {
"bLengthChange": false,
"scrollX": true,
"lengthMenu": [ [-1], ["All"] ]
} );
$('#ptsTab').dataTable( {
"bLengthChange": false,
"scrollX": true,
"lengthMenu": [ [-1], ["All"] ]
} );
$('#sortantTab').dataTable( {
"bLengthChange": false,
"scrollX": true,
"lengthMenu": [ [-1], ["All"] ]
} );
} );
</script>
</head>
<body>
<label for="" id="Label2" style="position:absolute;left:8px;top:11px;width:1245px;height:19px;line-height:19px;z-index:21;">Contrôle commande niveau cellule</label>
<label for="" id="Label5" style="position:absolute;left:405px;top:50px;width:116px;height:19px;line-height:19px;z-index:22;">Silo :</label>
<label for="" id="Label1" style="position:absolute;left:685px;top:50px;width:116px;height:19px;line-height:19px;z-index:23;">Cellule :</label>
<div id="jQTHisto" style="position:absolute;left:8px;top:125px;width:1243px;height:507px;z-index:24;">
<ul>
<li><a href="#jqthisto-page-0"><span>Historique des mouvements entrants</span></a></li>
<li><a href="#jqthisto-page-1"><span>Historique des points 0</span></a></li>
<li><a href="#jqthisto-page-2"><span>Historique des mouvements sortants</span></a></li>
</ul>
<div style="height:485px;" id="jqthisto-page-0">
<label for="" id="Label4" style="position:absolute;left:288px;top:63px;width:116px;height:19px;line-height:19px;z-index:0;">Cellule :</label>
<input type="text" id="Editbox3" style="position:absolute;left:359px;top:61px;width:60px;height:20px;line-height:20px;z-index:1;" name="Editbox1" value="{{full}}" spellcheck="false" class="span3 datatab">
<label for="" id="Label6" style="position:absolute;left:451px;top:63px;width:116px;height:19px;line-height:19px;z-index:2;">Espèce :</label>
<input type="text" id="Editbox4" style="position:absolute;left:523px;top:61px;width:60px;height:20px;line-height:20px;z-index:3;" name="Editbox1" value="{{cellule}}" spellcheck="false" class="span3 datatab">
<label for="" id="Label7" style="position:absolute;left:617px;top:63px;width:116px;height:19px;line-height:19px;z-index:4;">Produit :</label>
<input type="text" id="Editbox5" style="position:absolute;left:689px;top:61px;width:60px;height:20px;line-height:20px;z-index:5;" name="Editbox1" value="{{cellule}}" spellcheck="false" class="span3 datatab">
<div id="Html6" style="position:absolute;left:12px;top:101px;width:1222px;height:400px;z-index:6">
<table id="entrantTab" class="display" width="100%" cellspacing="0">
<thead>
<tr>
<th>Date et heure création</th>
<th>Récolte</th>
<th>Mouvement</th>
<th>Sous domaine</th>
<th>Produit</th>
<th>Poids</th>
<th>Livreur</th>
<th>Immatriculation</th>
<th>Code Caract 1</th>
<th>Valeur Caract 1</th>
<th>Code Caract 2</th>
<th>Valeur Caract 2</th>
<th>Code Caract 3</th>
<th>Valeur Caract 3</th>
<th>Code Caract 4</th>
<th>Valeur Caract 4</th>
<th>Code Caract 5</th>
<th>Valeur Caract 5</th>
<th>Code Caract 6</th>
<th>Valeur Caract 6</th>
<th>Code Caract 7</th>
<th>Valeur Caract 7</th>
<th>Code Caract 8</th>
<th>Valeur Caract 8</th>
<th>Code Caract 9</th>
<th>Valeur Caract 9</th>
<th>Code Caract 10</th>
<th>Valeur Caract 10</th>
</tr>
</thead>
<tbody>
{% for mouvement in mouvementRCPs %}
<th>{{mouvement.Datetime2}}</th>
<th>{{mouvement.Recolte}}</th>
<th>{{mouvement.Type_Mouvement}}</th>
<th>{{mouvement.Sous_Domaine}}</th>
<th>{{mouvement.Produit}}</th>
<th>{{mouvement.Poids}}</th>
<th>{{mouvement.Livreur}}</th>
<th>{{mouvement.Immat}}</th>
<th>{{mouvement.CodeCaract1}}</th>
<th>{{mouvement.Val_Caract1}}</th>
<th>{{mouvement.Code_Carac}}</th>
<th>{{mouvement.Val_Caract2}}</th>
<th>{{mouvement.Code_Caract3}}</th>
<th>{{mouvement.Val_Caract3}}</th>
<th>{{mouvement.Code_Caract4}}</th>
<th>{{mouvement.Val_Caract4}}</th>
<th>{{mouvement.Code_Caract5}}</th>
<th>{{mouvement.Val_Caract5}}</th>
<th>{{mouvement.Code_Caract6}}</th>
<th>{{mouvement.Val_Caract6}}</th>
<th>{{mouvement.Code_Caract7}}</th>
<th>{{mouvement.Val_Caract7}}</th>
<th>{{mouvement.Code_Caract8}}</th>
<th>{{mouvement.Val_Caract8}}</th>
<th>{{mouvement.CodeCaract9}}</th>
<th>{{mouvement.Val_Caract9}}</th>
<th>{{mouvement.Code_Caract10}}</th>
<th>{{mouvement.Val_Caract10}}</th>
</tr>
{% endfor %}
</tbody>
</table></div>
</div>
<div style="height:485px;" id="jqthisto-page-1">
<div id="htmlDateTimePicker3" style="position:absolute;left:20px;top:60px;width:250px;height:30px;z-index:0">
<div class="input-group date form_datetime col-md-5" data-date="2017-01-01T05:25:07Z" data-date-format="dd MM yyyy - hh:ii" data-link-field="dtp_input1" >
<input class="form-control" size="16" type="text" value='{{listPB.2}}' readonly>
<span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
</div>
</div>
<script>
$('.form_datetime').datetimepicker({
language: 'fr',
weekStart: 1,
todayBtn: 1,
autoclose: 1,
todayHighlight: 1,
startView: 2,
forceParse: 0,
minuteStep: 1,
});
</script>
<div id="htmlDateTimePicker4" style="position:absolute;left:20px;top:100px;width:250px;height:30px;z-index:0">
<div class="input-group date form_datetime col-md-5" data-date="2017-01-01T05:25:07Z" data-date-format="dd MM yyyy - hh:ii" data-link-field="dtp_input1" >
<input class="form-control" size="16" type="text" value='{{listPB.2}}' readonly>
<span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
</div>
</div>
<script>
$('.form_datetime').datetimepicker({
language: 'fr',
weekStart: 1,
todayBtn: 1,
autoclose: 1,
todayHighlight: 1,
startView: 2,
forceParse: 0,
minuteStep: 1,
});
</script>
<label for="" id="Label3" style="position:absolute;left:288px;top:63px;width:116px;height:19px;line-height:19px;z-index:9;">Cellule :</label>
<input type="text" id="Editbox2" style="position:absolute;left:359px;top:61px;width:60px;height:20px;line-height:20px;z-index:10;" name="Editbox1" value="{{cellule}}" spellcheck="false" class="span3 datatab">
<div id="Html7" style="position:absolute;left:272px;top:101px;width:962px;height:400px;z-index:11">
<table id="ptsTab" class="display" width="100%" cellspacing="0">
<thead>
<tr>
<th>Date et heure création</th>
<th>Type deMouvement</th>
</tr>
</thead>
<tbody>
{% for mouvement in mouvementPT0s %}
<th>{{mouvement.Datetime2}}</th>
<th>{{mouvement.Type_Mouvement}}</th>
</tr>
{% endfor %}
</tbody>
</table></div>
</div>
<div style="height:485px;" id="jqthisto-page-2">
<div id="htmlDateTimePicker5" style="position:absolute;left:20px;top:60px;width:250px;height:30px;z-index:0">
<div class="input-group date form_datetime col-md-5" data-date="2017-01-01T05:25:07Z" data-date-format="dd MM yyyy - hh:ii" data-link-field="dtp_input1" >
<input class="form-control" size="16" type="text" value='{{listPB.2}}' readonly>
<span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
</div>
</div>
<script>
$('.form_datetime').datetimepicker({
language: 'fr',
weekStart: 1,
todayBtn: 1,
autoclose: 1,
todayHighlight: 1,
startView: 2,
forceParse: 0,
minuteStep: 1,
});
</script>
<div id="htmlDateTimePicker6" style="position:absolute;left:20px;top:100px;width:250px;height:30px;z-index:0">
<div class="input-group date form_datetime col-md-5" data-date="2017-01-01T05:25:07Z" data-date-format="dd MM yyyy - hh:ii" data-link-field="dtp_input1" >
<input class="form-control" size="16" type="text" value='{{listPB.2}}' readonly>
<span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
</div>
</div>
<script>
$('.form_datetime').datetimepicker({
language: 'fr',
weekStart: 1,
todayBtn: 1,
autoclose: 1,
todayHighlight: 1,
startView: 2,
forceParse: 0,
minuteStep: 1,
});
</script>
<label for="" id="Label8" style="position:absolute;left:288px;top:62px;width:116px;height:19px;line-height:19px;z-index:14;">Cellule :</label>
<input type="text" id="Editbox6" style="position:absolute;left:359px;top:60px;width:60px;height:20px;line-height:20px;z-index:15;" name="Editbox1" value="{{cellule}}" spellcheck="false" class="span3 datatab">
<label for="" id="Label9" style="position:absolute;left:451px;top:62px;width:116px;height:19px;line-height:19px;z-index:16;">Espèce :</label>
<label for="" id="Label10" style="position:absolute;left:617px;top:62px;width:116px;height:19px;line-height:19px;z-index:17;">Produit :</label>
<input type="text" id="Editbox7" style="position:absolute;left:523px;top:60px;width:60px;height:20px;line-height:20px;z-index:18;" name="Editbox1" value="{{cellule}}" spellcheck="false" class="span3 datatab">
<input type="text" id="Editbox8" style="position:absolute;left:689px;top:60px;width:60px;height:20px;line-height:20px;z-index:19;" name="Editbox1" value="{{cellule}}" spellcheck="false" class="span3 datatab">
<div id="Html8" style="position:absolute;left:275px;top:100px;width:962px;height:400px;z-index:20">
<table id="sortantTab" class="display" width="100%" cellspacing="0">
<thead>
<tr>
<th>Date et heure création</th>
<th>Récolte</th>
<th>Mouvement</th>
<th>Sous domaine</th>
<th>Produit</th>
<th>Poids</th>
<th>Livreur</th>
<th>Immatriculation</th>
<th>Code Caract 1</th>
<th>Valeur Caract 1</th>
<th>Code Caract 2</th>
<th>Valeur Caract 2</th>
<th>Code Caract 3</th>
<th>Valeur Caract 3</th>
<th>Code Caract 4</th>
<th>Valeur Caract 4</th>
<th>Code Caract 5</th>
<th>Valeur Caract 5</th>
<th>Code Caract 6</th>
<th>Valeur Caract 6</th>
<th>Code Caract 7</th>
<th>Valeur Caract 7</th>
<th>Code Caract 8</th>
<th>Valeur Caract 8</th>
<th>Code Caract 9</th>
<th>Valeur Caract 9</th>
<th>Code Caract 10</th>
<th>Valeur Caract 10</th>
</tr>
</thead>
<tbody>
{% for mouvement in mouvementCHGs %}
<th>{{mouvement.Datetime2}}</th>
<th>{{mouvement.Recolte}}</th>
<th>{{mouvement.Type_Mouvement}}</th>
<th>{{mouvement.Sous_Domaine}}</th>
<th>{{mouvement.Produit}}</th>
<th>{{mouvement.Poids}}</th>
<th>{{mouvement.Livreur}}</th>
<th>{{mouvement.Immat}}</th>
<th>{{mouvement.CodeCaract1}}</th>
<th>{{mouvement.Val_Caract1}}</th>
<th>{{mouvement.Code_Carac}}</th>
<th>{{mouvement.Val_Caract2}}</th>
<th>{{mouvement.Code_Caract3}}</th>
<th>{{mouvement.Val_Caract3}}</th>
<th>{{mouvement.Code_Caract4}}</th>
<th>{{mouvement.Val_Caract4}}</th>
<th>{{mouvement.Code_Caract5}}</th>
<th>{{mouvement.Val_Caract5}}</th>
<th>{{mouvement.Code_Caract6}}</th>
<th>{{mouvement.Val_Caract6}}</th>
<th>{{mouvement.Code_Caract7}}</th>
<th>{{mouvement.Val_Caract7}}</th>
<th>{{mouvement.Code_Caract8}}</th>
<th>{{mouvement.Val_Caract8}}</th>
<th>{{mouvement.CodeCaract9}}</th>
<th>{{mouvement.Val_Caract9}}</th>
<th>{{mouvement.Code_Caract10}}</th>
<th>{{mouvement.Val_Caract10}}</th>
</tr>
{% endfor %}
</tbody>
</table></div>
</div>
</div>
<div id="htmlDateTimePicker1" style="position:absolute;left:20px;top:60px;width:250px;height:30px;z-index:0">
<div class="input-group date form_datetime col-md-5" data-date="2017-01-01T05:25:07Z" data-date-format="dd MM yyyy - hh:ii" data-link-field="dtp_input1" >
<input class="form-control" size="16" type="text" value='{{listPB.2}}' readonly>
<span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
</div>
</div>
<script>
$('.form_datetime').datetimepicker({
language: 'fr',
weekStart: 1,
todayBtn: 1,
autoclose: 1,
todayHighlight: 1,
startView: 2,
forceParse: 0,
minuteStep: 1,
});
</script>
<div id="htmlDateTimePicker2" style="position:absolute;left:20px;top:100px;width:250px;height:30px;z-index:0">
<div class="input-group date form_datetime col-md-5" data-date="2017-01-01T05:25:07Z" data-date-format="dd MM yyyy - hh:ii" data-link-field="dtp_input1" >
<input class="form-control" size="16" type="text" value='{{listPB.2}}' readonly>
<span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
</div>
</div>
<script>
$('.form_datetime').datetimepicker({
language: 'fr',
weekStart: 1,
todayBtn: 1,
autoclose: 1,
todayHighlight: 1,
startView: 2,
forceParse: 0,
minuteStep: 1,
});
</script>
<input type="text" id="ebVehicule" style="position:absolute;left:459px;top:48px;width:60px;height:20px;line-height:20px;z-index:27;" name="Editbox1" value="{{silo}}" spellcheck="false" class="span3 datatab">
<input type="text" id="Editbox1" style="position:absolute;left:767px;top:48px;width:69px;height:20px;line-height:20px;z-index:28;" name="Editbox1" value="{{cellule}}" spellcheck="false" class="span3 datatab">
</body>
</html>
由于我目前无法使用固定日期调用该过程。 我想要做的是用户进入页面,选择两个日期,点击研究按钮,然后回调视图以使用正确的参数调用过程,然后用结果填充数据表