Django models 我在定义入口模型时遇到问题,我一直在使用Meta类得到TypeError
我一直遇到Django models 我在定义入口模型时遇到问题,我一直在使用Meta类得到TypeError,django-models,Django Models,我一直遇到TypeError:“Class Meta”的属性无效:verbos\u name\u复数。 from django.db import models # Create your models here. #Class for topic. class Topic(models.Model): """A topic the use is learning about""" text = models.CharField(max_length=200) dat
TypeError:“Class Meta”的属性无效:verbos\u name\u复数。
from django.db import models
# Create your models here.
#Class for topic.
class Topic(models.Model):
"""A topic the use is learning about"""
text = models.CharField(max_length=200)
date_added = models.DateTimeField(auto_now_add=True)
def __str__(self):
"""Retun a string representation of the model."""
return self.text
class Entry(models.Model):
"""Something specific learned about a topic"""
topic = models.ForeignKey(Topic,on_delete=models.CASCADE)
text = models.TextField()
date_added = models.DateTimeField(auto_now_add = True)
class Meta:
verbos_name_plural = 'entries'
def __str__(self):
"""Return a string representation of the model."""
return self.text[:50] + "..."
这段代码实际上让我很难定义条目模型,我尝试从代码中删除类元,因为这是我第一次遇到的错误,但在删除类元后,我仍然遇到类主题的错误。如果有人能帮助我,我将非常高兴。应该是这样的
class Meta:
verbose_name_plural = 'entries'
而不是
class Meta:
verbos_name_plural = 'entries'
它是verbose\u name\u复数
,而不是verbos\u name\u复数
。(在verbose
的末尾有一个e
)非常感谢@WillemVanOnsem,我添加了(e)并成功了。