【发布时间】:2022-02-02 03:18:45
【问题描述】:
import pandas as pd
from django.shortcuts import render
# Create your views here.
def home():
data = pd.read_csv("\\pandadjangoproject\\nmdata.csv", nrows=11)
only_city = data[['name']]
context = {
"data": data.to_html(index=False),
"only_city": only_city.to_html()
}
return request(render, 'home.html', context)
#Here is my HTML Page
<html>
<head>
<title>NM Biggest citys</title>
</head>
<body>
<h1>New Mexicos Largest Citys</h1>
{{only_city|safe}}
</body>
</html>
#我得到这个错误:
类型错误在 /
home() 接受 0 个位置参数,但给出了 1 个
请求方法:GET
请求网址:http://localhost:8000/
Django 版本:4.0.1
异常类型:TypeError
异常值:
home() 接受 0 个位置参数,但给出了 1 个
【问题讨论】:
-
你怎么打电话给
home()?