更新PYTHON MONGODB(缺少1个必需的位置参数:self)

2024-09-30 18:18:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我对金字塔中的python环境还不熟悉。我的更新代码在第76行中不断出现错误“missing 1 required positional argument:self” waterUpdate1=water1.update(值=1,volumeInitial=volInitial)

下面是我的更新代码默认.py你知道吗

    #Update Code in default.py
    @view_config(route_name = 'ajax',
            match_param = 'action=waterNow1',
            renderer = 'json')

    def waterNow1(self):
        volInitial = int(self.paramValues('waterVol'))
Line 76 waterUpdate1 = water1.update(value = 1, volumeInitial = volInitial)
        vol = water1(value = 1,volumeInitial = volInitial)
        vol.save()
        waterUpdate2 = water1.update(value = 0, volumeInitial = 0)
        return {"waterUpdate1":update.to_json(),"waterUpdate2":update.to_json()}
        return self.returnSuccess()

下面是我的密码型号.py你知道吗

    # models.py
    class water1(DynamicDocument):
        value = IntField()
          volumeInitial = IntField()

下面是我的jinja2功能代码

<!-- Water Now -->
    <script>
        $(document).ready(function(){
            $("#water1").unbind('click').bind('click', function(e){
                var vol = $("#vol1").val();
                e.preventDefault();
                $.post(
                'ajax/waterNow1',
                {
                    'waterVol':vol
                }, function(data, status){
                    if(data.success){
                        Swal.fire({
                        type: 'success',
                        title: 'Watering Vessel A with 10 mL of Water',
                        showConfirmButton: false,
                        timer: 5000
                        })

                        location.assign("dashboard");
                    } else {
                        $("#error-message").html('<span class="glyphicon glyphicon-warning-sign"></span> '+data.message).css('color', 'red');
                    }
                });
            });
        });
    </script>

谢谢你。你知道吗


Tags: 代码pyselfjsondatavalueupdateajax