I have a seemingly harmless but very niggling error in my admin panel:
It erroneously produces the output "Teacherss" (double ss) and I cannot see why this occurs from my code:
So the models.py in the teachers app is:
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)
The admin.py file has this:
from django.contrib import admin
from main.models import Teachers
# Register your models here.
admin.site.register(Teachers)
Any idea why this is generated in the admin panel?
MAIN Teacherss Add/Change
Where is the double ss coming from and how do I get rid of it!??
UPDATE BASED ON ANSWERS
Update: Interesting to note from the answers below that singular must be used. I did however change my code and now the following error arises:
Error
In admin.py from main.models import Teacher Import Error: cannot import name 'Teacher'
admin.py file
from django.contrib import admin
from main.models import Teacher
# Register your models here.
admin.site.register(Teacher)
models.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)
...problem resolved. I hadn't called the app in the import models (main.models had been written instead of teachers.models).
Thank you for the below answers
By default Django expects your model to have a name in singular, i.e., Teacher
. It also by default attaches an s
to your model's name to show it in the admin. This can be configured from inside your model itself.