我的管理面板中有一个看似无害但非常琐碎的错误:
它错误地产生输出“teachers”(双ss),我无法从代码中理解为什么会出现这种情况:
模型也是如此。教师应用程序中的py为:
class Teachers(models.Model):
#this is what an album is going to be made of
email=models.CharField(max_length=250)
school_name=models.CharField(max_length=500)
password=models.CharField(max_length=100)
class_name=models.CharField(max_length=100)
管理员。py文件具有以下内容:
from django.contrib import admin
from main.models import Teachers
# Register your models here.
admin.site.register(Teachers)
你知道为什么会在管理面板中生成这个吗?
主要
教师添加/更改
双ss是从哪里来的?我该如何摆脱它!??
根据答案更新
更新:有趣的是,下面的答案中必须使用单数。但是,我确实更改了代码,现在出现了以下错误:
在管理中。py公司
来自main。模型导入教师
导入错误:无法导入名称“Teacher”
管理py文件
from django.contrib import admin
from main.models import Teacher
# Register your models here.
admin.site.register(Teacher)
模型。py公司
from django.db import models
# Create your models here.
class Teacher(models.Model):
#this is what an album is going to be made of
email=models.CharField(max_length=250)
school_name=models.CharField(max_length=500)
password=models.CharField(max_length=100)
class_name=models.CharField(max_length=100)
#You need this for meta data purposes. This allows you to reference the post (otherwise it will just print the object which doesn't mean much)
#You need this for meta data purposes. This allows you to reference the post (otherwise it will just print the object which doesn't mean much)
...问题已解决。我没有在导入模型中调用该应用程序(main.models是编写的,而不是teachers.models)。
感谢您提供以下答案