Home > Web Front-end > HTML Tutorial > Python Django 在html显示mysql的数据_html/css_WEB-ITnose

Python Django 在html显示mysql的数据_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:16:31
Original
1650 people have browsed it

各位老师,本人用Python 2.7+Django1.8+mysql搭建环境,目前html能实现的功能如图1所示:
,实现的代码就是如下所示。
但是我想在html右边的框里显示Mysql的数据(数据已经通过python添加,但是显示不出来),请问怎么修改html的代码才能显示出数据来呢?谢谢。

我的Model代码如下:

from django.db import models
from django.contrib import admin
class OFCT(models.Model):
    Year=models.IntegerField(verbose_name='Year',blank=False,null=False)
    Authorize_Supplier_Payment_Cycle_Time=models.DecimalField(max_digits=4,decimal_places=2,blank=True,null=True)
    Identify_Sources_of_Supply_Cycle_Time=models.DecimalField(max_digits=4,decimal_places=2,blank=True,null=True)
    
url代码如下:

from django.conf.urls import patterns, include, url
from django.contrib import admin
from metrics import views
admin.autodiscover()

urlpatterns = patterns('',
    url(r'^login/',include('login.urls')),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^OFCT/$','metrics.views.OFCT'),
)

Views代码如下:

def OFCT(request):
    return render_to_response('OFCT.html',locals())

HTML代码如下:




    OFCT Level-3 metrics


  
{% block title %}OFCT Level-3 Metrics{% endblock %}
{% block content %}

    
         







                        
Year {{ OFCT.Year }}
Authorize_Supplier_Payment_Cycle_Time {{ OFCT.Authorize_Supplier_Payment_Cycle_Time }}

{% endblock %}



回复讨论(解决方案)

如何解决的 ??请问

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template