guopengfa
发布于 2020-05-30 / 741 阅读 / 0 评论 / 0 点赞

django使用pandas实例化model

from django.shortcuts import render
from modelTest.models import Test1
from django.http import HttpResponse
import pickle
import json
import pandas as pd

Create your views here.

def modelvalue(request):
value = Test1.objects.all()
value = value.values()
value = pd.DataFrame(value)
value = value.keys().tolist()
return render(request,"index.html",{"value":value})


评论