0
Follow
0
View

python value deletion problem

leila0329 注册会员
2023-02-28 19:10

This answer quotes ChatGPT

Depending on the information you provided, it may be because you encountered a type error while converting del_d to an integer. Try to convert it to an integer using the following code:

def del(request):
    del_d = request.GET.get("del")
    del_id = int(del_d)
    print(del_id)
    models.qq_news.objects.filter(id=del_id).delete()
    return redirect('/data_enter/')

If this doesn't work, you can try using the try and except statements to catch the exception and debug it:


def data_del(request):
    del_d = request.GET.get("del")
    try:
        del_id = int(del_d)
    except TypeError:
        print("del_d is not a valid integer.")
    else:
        print(del_id)
        models.qq_news.objects.filter(id=del_id).delete()
    return redirect('/data_enter/')

Also, you mentioned that there is no problem on Windows, but there is a problem on CentOS. This may be due to differences in the operating system environment. You can try to check whether the Python version and dependency library version you use on CentOS are the same as those on Windows. In addition, you can check your log file or console output to see if there are any additional error messages.

dishu3 注册会员
2023-02-28 19:10
[28日/ 2月/ 2023 17:15:20]“GET / del / HTTP / 1.0”302 0

eank007 注册会员
2023-02-28 19:10

I mean print the original del_d, before conversion.

falwyvemmmm 注册会员
2023-02-28 19:10
< div class = "md_content_show e397 data - v - 3967" = "" >

the STR string

wangxianchun 注册会员
2023-02-28 19:10

What does print(del_d) print out in view function?

dyzklq 注册会员
2023-02-28 19:10
< div class = "md_content_show e397 data - v - 3967" = "" >

STR using int translation error directly

About the Author

Question Info

Publish Time
2023-02-28 19:10
Update Time
2023-02-28 19:10