SDUVJ开发实录(四):Problem与ProblemList显示

来源:互联网 发布:水资源优化配置 编辑:程序博客网 时间:2024/05/22 05:24

使用Django进行SDUVJ的题目和数据显示。
在已有的数据库的条件下,使用pymysql+Django先实现对题目的显示:

db = pymysql.connect("211.87.227.207","vj","passwordiswrongdontmind","vj")def problem_details(request):    sql = "select * from problem" \            " where proid='100000'"    cursor = db.cursor()    content = {}    try:        cursor.execute(sql)        results = cursor.fetchall()        for row in results:            content['problemId'] = row[0]            content['problem_title'] = row[4]            content['problem_limit_time'] = row[5]            content['problem_limit_memory'] = row[6]            content['problem_content'] = row[7]            content['problem_input'] = row[8]            content['problem_output'] = row[9]            content['s_input'] = row[10]            content['s_output'] = row[11]        content['status'] = 'YES'    except:        db.rollback()        content['status'] = 'NO'    return render(request, 'problem/problem_detail.html', content)    return render(request, 'demo.html', content)

显示如下:
这里写图片描述

在针对ProblemList的显示中,由于Problem.html模板需要做到分页,所以遇到了一些问题,题目无法正常显示。
这里写图片描述

分析应该是原SDUOJ使用了Django的QueryAPI,与测试中使用的pymysql出现了冲突。
在下一个工作周期将着力解决这个问题。

原创粉丝点击