Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/23.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
Python ';int';对象在访问多值django时没有属性get错误_Python_Django - Fatal编程技术网

Python ';int';对象在访问多值django时没有属性get错误

Python ';int';对象在访问多值django时没有属性get错误,python,django,Python,Django,我想访问在某些元素中具有相同id/类的多值 我将给出一些代码来说明这一点 html 当我试图用我放在html中的按钮显示查询时,它总是在命令提示符下出现错误,'int'对象没有属性get或者'str'对象没有属性get,ajax响应将是“error occurrend”,因为它失败了 我希望有人能帮助修复我的代码,并感谢您的帮助后者column=request.get.get('condition',1')。get('column',1)导致了错误。通过第二次调用get,您试图实现什么?@Ped

我想访问在某些元素中具有相同id/类的多值

我将给出一些代码来说明这一点

html

当我试图用我放在html中的按钮显示查询时,它总是在命令提示符下出现错误,
'int'对象没有属性get或者'str'对象没有属性get
,ajax响应将是
“error occurrend”
,因为它失败了


我希望有人能帮助修复我的代码,并感谢您的帮助

后者
column=request.get.get('condition',1')。get('column',1)
导致了错误。通过第二次调用get,您试图实现什么?@PedramParsian如果您可以看到ajax将发送类似于条件[]中的值,您将推送类似“列”、“运算符”和“值”的数据,因为如果用户想要添加新列,它将包含多值,因此,我认为它将成为一个列表/数组列表。第二次调用我想在条件数据中获取一个特定项,就像我想在条件数据中调用列变量值一样,这就是为什么我尝试获取条件,然后获取列@PedramParsian
var condition=request.get.get('condition',1)
然后使用
condition[“column”]
获取列值
<div class="row mt">
          <div class="col-lg-12">
            <div class="form-panel">
              <form class="form-horizontal  style-form" action="#">
                <div class="form-group">
                  <label class="control-label col-md-3">Database Name</label>
                  <div class="col-md-4">
                    <div class="input-group bootstrap-timepicker">
                      <div class="btn-group">
                            <select id = "tableselect"  style="width:425px;background-color:white;height:30px;font-color:red;text-align-last:center;">              
                            <!-- <li><a href="#"></a></li> -->
                            {% for table in obj2 %}
                                    <option value = "{{table}}" >{{ table }}</option>
                            {% endfor %}                          
                            <!-- <li><a href="#">Dropdown link</a></li> -->
                            </option>
                            </select>                    
                      </div>
                    </div>
                  </div>
                </div>
                <div class="form-group">
                  <label class="control-label col-md-3">Table Name</label>
                  <div class="col-md-4">
                    <div class="input-group bootstrap-timepicker">
                       <div class="btn-group">
                            <select id="dataselect" style="width:425px;background-color:white;height:30px;font-color:red;text-align-last:center;">            
                            </select>                    
                      </div>
                    </div>
                  </div>
                </div>
                <div class="form-group">
                  <button class="btn btn-theme" onclick="return appendBox()">Add</button>
                  <label class="control-label col-md-3">Column Name</label> 
                  <div class="col-md-4" id ="test">

                       <div class="btn-group">
                            <select class = "columnselect" style="width:425px;background-color:white;height:30px;font-color:red;text-align-last:center;">              
                            </select>                
                      </div>

                  </div>
                </div>
                <div class="form-group">
                  <button class="btn btn-theme" onclick=" return appendFilterBox()">Add</button>
                  <label class="control-label col-md-3">Filter</label>
                  <div class="col-md-4" id="filtbox">
                    <div class="input-group bootstrap-timepicker">
                       <div class="btn-group">                          
                            <select class="conditionselect" style="width:150px;background-color:white;height:30px;font-size:15px;text-align-last:center;">                                          
                            </select>    
                            <select id="operator" style="width:120px;background-color:white;height:30px;font-size:15px;text-align-last:center;">              
                                <option> > </option>
                                <option> < </option>
                                <option> ≥ </option>
                                <option> ≤ </option>
                                <option> = </option>
                            </select>  
                            <input id="parameter" type="text" style="width:150px;background-color:white;height:30px;font-size:15px;text-align-last:center;">                                          
                            </input>                                                                 
                      </div>
                    </div>
                  </div>
                </div>
                <div class="form-group">                                                    
                  <div class="col-md-4" id="showquery">
                    <div class="input-group bootstrap-timepicker">
                       <div class="btn-group">             
                        <button id="result" class="btn btn-theme" type="submit" style="height:30px;width:100px;" onclick="return showQuery()">Show</button>

                        <button id="export" class="btn btn-theme" type="Export" style="height:30px;width:100px;" onclick="return ExportFile()">Export</button>
                       </div>
                     </div>
                   </div>
                 </div>


<script>
      function appendBox()
      {
          $('#test').append('<select class = "columnselect" style="width:425px;background-color:white;height:30px;font-color:red;text-align-last:center;"></select>')
            return false
      }
  </script>

  <script>
      function appendFilterBox()
      {
            $('#filtbox').append('<select class="columnselect" style="width:125px;background-color:white;height:30px;font-size:15px;text-align-last:center;margin-top:5px;margin-right:2px"></select><select class="" style="width:125px;background-color:white;height:3 0px;font-size:15px;text-align-last:center;margin-top:5px;margin-right:3px"><option> > </option><option> < </option><option> ≥ </option><option> ≤ </option><option> = </option></select><input type="text" style="width:150px;background-color:white;height:30px;font-size:15px;"></input>')
              return false
      }
  </script>

<script>
      $(document).ready(function() {
      $("#result").click(function () {
        var urls = "{% url 'polls:load-query' %}";
        var table = $('#dataselect').val();

      data = {
        'name' : [],
        'table': table,
        'condition': []
      };

        $('#column-name .columnselect').each((idx, el) => data.name.push($(el).val()));
        $('#filtbox .input-group').each((idx, el) => {
          condition = {
            'column' : $(el).find('.conditionselect').val(),
            'operator' : $(el).find('#operator').val(),
            'value' : $(el).find('#parameter').val()
          };
          data.condition.push(condition);
        });

        $.ajax({                     
          url: urls,                    
          data: data,
          success: function(data) {   
              $("#query_result").html(data);  
          },
          error: function(data)
          {
            alert("error occured");
          }
        });
      });
      });
  </script> 
def list_all_data(request):
    import cx_Oracle
    dsn_tns = cx_Oracle.makedsn('', '', sid='') 
    conn = cx_Oracle.connect(user=r'', password='', dsn=dsn_tns) 
    c = conn.cursor()

    data_name = request.GET.get('name',1)
    print(data_name)
    table_name = request.GET.get('table',1)
    print(table_name)
    column = request.GET.get('condition',1).get('column',1)
    operator = request.GET.get('condition',1).get('operator',1)
    value = request.GET.get('condition',1).get('value',1)

    c.execute("select "+data_name+" from "+table_name+" where "+column + operator+"'"+value+"'")

    c.rowfactory = makeDictFactory(c)
    columnalldata = []
    columnallname = []

    for rowDict in c:
        columnalldata.append(rowDict[data_name])
        columnallname.append(data_name)

    context = {
        'obj4' : columnalldata,
        'column_name' : columnallname
    }
    return render(request,'query_result.html',context)