Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django请求将自动启动_Django - Fatal编程技术网

Django请求将自动启动

Django请求将自动启动,django,Django,我遇到了一个小问题,我不记得如何解决我的问题 我有一个模板,让查询数据库,并根据用户的条件得到一个结果 我的观点是: @login_required def Identity_Individu_Researching(request) : query_lastname_ID = request.GET.get('q1ID') query_firstname_ID = request.GET.get('q1bisID') query_naissance_ID = requ

我遇到了一个小问题,我不记得如何解决我的问题

我有一个模板,让查询数据库,并根据用户的条件得到一个结果

我的观点是:

@login_required
def Identity_Individu_Researching(request) :

    query_lastname_ID = request.GET.get('q1ID')
    query_firstname_ID = request.GET.get('q1bisID')
    query_naissance_ID = request.GET.get('q1terID')

    sort_params = {}

    set_if_not_none(sort_params, 'id__gt', query_lastname_ID)
    set_if_not_none(sort_params, 'Prenom__icontains', query_firstname_ID)
    set_if_not_none(sort_params, 'VilleNaissance', query_naissance_ID)

    query_ID_list = Individu.objects.filter(**sort_params) 

    return render(request, 'Identity_Individu_Recherche.html', context)
但此请求在加载模板时自动启动

在我的HTML模板中,我有:

<form autocomplete="off" method="GET" action="">
            <input type="text"  name="q1ID" placeholder="Nom (ex:TEST) " value="{{ request.GET.q1ID }}"> et
            <input type="text"  name="q1bisID" placeholder="Prénom (ex:Test)" value="{{ request.GET.q1bisID }}"> &nbsp;
            <input type="text"  name="q1terID" placeholder="Ville Naissance" value="{{ request.GET.q1terID }}"> (optionnel)
            <input class="button" type="submit" name="recherche" value="Rechercher">&nbsp;
        </form>

        <br></br>

        <table style="width:120%">
            <tbody>
                <tr>
                    <th>ID</th>
                    <th>État</th>
                    <th>N° Identification</th>
                    <th>Civilité</th>
                    <th>Nom</th>
                    <th>Prénom</th>
                    <th>Date de Naissance</th>
                    <th>Ville de Naissance</th>
                    <th>Pays de Naissance</th>
                    <th>Institution</th>
                </tr>
                {% for item in query_ID_list %}
                <tr>
                    <td>{{ item.id}}</td>
                    <td>{{ item.Etat}}</td>
                    <td>{{ item.NumeroIdentification}}</td>
                    <td>{{ item.Civilite }}</td>
                    <td>{{ item.Nom }}</td>
                    <td>{{ item.Prenom }}</td>
                    <td>{{ item.DateNaissance }}</td>
                    <td>{{ item.VilleNaissance }}</td>
                    <td>{{ item.PaysNaissance }}</td>
                    <td>{{ item.InformationsInstitution }}</td>
                </tr>
                {% endfor %}
            </tbody>
        </table>

et
(可选)


身份证件 埃塔 N°识别 文明 笔名 名词 出生日期 新生维尔 德纳桑斯酒店 机构 {查询\u ID\u列表%中的项的百分比} {{item.id} {{item.Etat} {{item.numeriodentification} {{item.Civilite}} {{item.Nom} {{item.Prenom} {{item.DateNaissance} {{item.VilleNaissance} {{item.PaysNaissance} {{item.InformationsInstitution} {%endfor%}

那么,只有当用户使用表单按钮提交表单时,我如何才能启动queryset呢?我知道它基于
name=“jhjh”

您可以在模板中更改表单的方法

<form autocomplete="off" method="POST" action="">
<!--                             ^^^^^        -->

您可以在模板中更改表单的方法

<form autocomplete="off" method="POST" action="">
<!--                             ^^^^^        -->

您应该检查请求是否包含表单数据

if 'recherche' in request.GET:
    ...

您应该检查请求是否包含表单数据

if 'recherche' in request.GET:
    ...

POST通常不适用于搜索表单。POST通常不适用于搜索表单。