I get the error : (admin.E108) The value of 'list_display[1]' refers to 'label', which is not a callable, an attribute of 'OrgAdmin', or an attribute or method on 'org.Org'. when I try to remove the field label, I don't understand why. (sqlite3)
It feels like django has referenced that field somewhere (I was using it in the str function before refactoring and I don't know how to sync it up or something.
from django.db import models
class Org(models.Model):
class Meta:
# https://docs.djangoproject.com/en/2.1/ref/models/options/#django.db.models.Options.db_table
db_table = "tfp_backoffice_org"
verbose_name = 'Organization'
# https://docs.djangoproject.com/en/2.1/ref/models/options/#indexes
indexes = [
models.Index(fields=['name', 'name']),
]
name = models.CharField(
help_text="Optional (autogenerated).<br />"
"Must be url-compliant (slug, using '-' dash separator, no space, special char, etc.)",
max_length=100,
)
label = models.CharField(
help_text="Label displayed in French language",
max_length=100,
)
label_fr = models.CharField(
help_text="Label displayed in French language",
max_length=100,
blank=True,
default="",
)
label_en = models.CharField(
help_text="Label displayed in English language",
max_length=100,
blank=True,
default="",
)
def __str__(self):
return self.label_fr
The error wasn't in the model (as stated in the error message) but in the admin.py file.
from django.contrib import admin
from org.models import Org
class OrgAdmin(admin.ModelAdmin):
list_display = ('name', 'label') # The error was there
admin.site.register(Org, OrgAdmin)
The problem was pretty obvious, I kept looking into the model.py instead of the admin.py. I guess I missed the obvious. Hope this helps someone in the future!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With