首页 > 解决方案 > 我在 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)

标签: pythondjangodjango-models

解决方案


我认为您在 views.py 中使用了错误的模型名称,在 views.py 中的 dj_app_accessrecord.data 状态的视图中使用 dj_app.AccessRecord.data


推荐阅读