python - 我在 django 管理中仅在访问记录中遇到操作错误
问题描述
我收到此错误:
我应该做些什么改变来消除这个错误?
这是我在models.py
文件中写的代码:
from django.db import models
# Create your models here.
class Topic(models.Model):
top_name = models.CharField(max_length=264,unique=True)
def __str__(self):
return self.top_name
class Webpage(models.Model):
topic = models.ForeignKey(Topic, on_delete=models.CASCADE)
name = models.CharField(max_length=264,unique=True)
url = models.URLField(unique=True)
def __str__(self):
return self.name
class AccessRecord(models.Model):
name = models.ForeignKey(Webpage, on_delete=models.CASCADE)
data = models.DateField()
def __str__(self):
return str(self.data)
解决方案
我认为您在 views.py 中使用了错误的模型名称,在 views.py 中的 dj_app_accessrecord.data 状态的视图中使用 dj_app.AccessRecord.data
推荐阅读
- node.js - 从 .json 文件创建 .env 文件
- python - 如何使用硒驱动程序python单击覆盖中的第一个链接
- ajax - 可以在ajax请求的响应中获取django设置的cookies
- reactjs - React:使变量在函数外重用
- ruby - Rails 无法在类初始化方法中生成实例变量以生成 httparty 请求
- python - np.save 生成的文件中的字节偏移量是否始终为 128?
- python - 如何在 Dash scatter 的图中为每个字典设置单独的名称?
- arrays - wp_query 仅从变量数组中返回第一个
- c# - 提取文本中的所有关键字并在每次匹配时分成 3 组
- javascript - 谷歌地图 api 看起来地址错误