[项目实训]VJ前端之Problem的显示
来源:互联网 发布:大岛凉花 知乎 编辑:程序博客网 时间:2024/06/13 01:41
首先从vj的数据库进去导入数据到本地并反向生成模型对象并存入app目录下的models.py
进入settings.py 配置数据库
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'vj', 'USER': 'root', 'PASSWORD': 'ssq960424', 'HOST': 'localhost', 'PORT': '3306' }}
同时因为使用mysql,修改项目根目录下的__init__.pyimport pymysqlpymysql.install_as_MySQLdb()
接着编写views.py,urls.py,前端模板在原有oj上可以借鉴稍作修改views.py
from django.shortcuts import renderfrom .models import *from django.forms.models import model_to_dict # Create your views here.def problem_detail(req, pid): problem = Problem.objects.get(problemid=pid) content = model_to_dict(problem) #content = {'originoj':'hdu','problemid':1001} return render(req,'problem/problem_detail.html',content)
problem_base.html
{% extends "base.html" %}{% block title %}{{ title }}{% endblock %}{% block navbar %}{% include "include/navbar-problem.html" %}{% endblock %}{% block header %} <div class="text-center"> <h1 class="text-success">{{ title }}</h1> <ul class="list-inline"> <li>Time Limit: {{ timelimit }}s</li> <li>Memory Limit: {{memorylimit}}</li> <li>Origin OJ: {{originoj}}</li> </ul> </div> <link rel="shortcut icon" href="/static/img/favicon.ico"> <meta charset="UTF-8"> <script src="http://cdn.bootcss.com/jquery/1.11.2/jquery.min.js"></script> <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.2/css/bootstrap.min.css"> <script src="http://cdn.bootcss.com/bootstrap/3.3.2/js/bootstrap.min.js"></script> <script src="/static/js/csrf.js"></script> <script src="/static/js/jquery.form.js"></script> <script type="text/javascript" src="/static/syntaxhighlighter/js/shCore.js"></script> <script type="text/javascript" src="/static/syntaxhighlighter/css/shBrushCpp.js"></script> <script type="text/javascript" src="/static/syntaxhighlighter/css/shBrushJava.js"></script> <link href="/static/syntaxhighlighter/css/shCore.css" rel="stylesheet" type="text/css"/> <link href="/static/syntaxhighlighter/css/shThemeDefault.css" rel="stylesheet" type="text/css"/>{% endblock %}{% block content %}<div class="panel panel-default"> {% include "problem/include/subnav.html" %}</div>{% block detail %}{% endblock %}{% endblock %}
problem_detail.html
{% extends "problem/problem_base.html" %}{% block detail %} <style type="text/css">pre{word-break: normal;word-wrap: break-word;white-space: pre-wrap;} </style> {% autoescape off %} <h3 class="text-info">Description</h3> <pre>{{ description }}</pre> <h3 class="text-info">Input</h3> <pre>{{ input }}</pre> <h3 class="text-info">Output</h3> <pre>{{ output }}</pre> {% endautoescape %} <h3 class="text-info">Sample Input</h3> <pre>{{ sampleinput }}</pre> <h3 class="text-info">Sample Output</h3> <pre>{{ sampleoutput }}</pre> {% autoescape off %} <h3 class="text-info" >Note</h3> <pre>{{ updatetime }}</pre> <h3 class="text-info">Source</h3> <pre>{{ originoj }} {{problemid}}</pre> {% endautoescape %}{% endblock %}
由于这周准备考试计划中的ProblemList的页面编写延后,同时发现数据库中的一些设计可能还有缺陷要与小伙伴们讨论下
阅读全文
0 0
- [项目实训]VJ前端之Problem的显示
- [项目实训]6.2 VJ整体的html页面的完善
- 关于VJ 的个人看法
- VJ水题堆:hdu 2045 不容易系列之(3)―― LELE的RPG难题
- 前端网页工程师项目实训教程(一)-在线商城的前端编码
- 超服贴!前端必修的项目练习之路
- 前端项目之CSS初始化
- 用VJ++实现FTP的功能
- 读《Microsoft VJ++的威胁》有感
- **VJ水题堆-sort函数的用法**
- SUST--vj的基本输入输出训练
- 窗口的最前端显示
- Django的前端页面显示
- 前端数字显示的格式
- Laravel框架之前端显示图片问题
- 前端项目的开发流程
- 前端开发规范之项目架构
- 前端开发规范之项目架构
- ubuntu 1604 native 原生安装 tensorflow 以及sonnet,无须编译bazel
- 【面试】String与数组中的length与length()
- eclipse 4.0+ tomcat重新发布问题
- echarts2的使用案例
- html中特殊符号表示
- [项目实训]VJ前端之Problem的显示
- swing设置字体
- ROS新版本Lunar Loggerhead
- Spring Cloud构建微服务架构(二)服务消费者
- [MacOS]MacOs的HomeBrew命令安装和常用工具(不断更新中)
- 饭店合同免费下载|股份合同免费|餐厅股份合作协议书
- Rsa算法
- 【Linux】VMware虚拟机中如何配置静态IP
- 解决ajax 传递为空但显示在页面上为undefined 问题