Reputation: 1
I've started Django for 2 days and I get stuck in this section. I want to change the admin section but my class couldn't inherit from (admin.modeladmin). when i want to use list_display,nothing load, and python give me this error:
<class 'django.contrib.auth.admin.GroupAdmin'>: (admin.E108) The value of 'list_display[0]' refers to 'title', which is not a callable, an attribute of 'GroupAdmin', or an attribute or method on 'auth.Group'. <class 'django.contrib.auth.admin.GroupAdmin'>: (admin.E108) The value of 'list_display[1]' refers to 'view', which is not a callable, an attribute of 'GroupAdmin', or an attribute or method on 'auth.Group'.
from django.contrib import admin
from .models import articles
class articlesAdmin(admin.ModelAdmin):
list_display=("title","view")
admin.site.register(articles)
how can i solve this?
Upvotes: 0
Views: 421
Reputation: 59
Try:
from django.contrib import admin
from .models import articles
class articlesAdmin(admin.ModelAdmin):
list_display = ("title","view",)
admin.site.register(articles,articlesAdmin)
Upvotes: 0
Reputation: 169368
admin.site.register
requires two parameters: the model object and the admin class.
admin.site.register(articles, articlesAdmin)
(As an aside, it's conventional to name all classes, including models, in PascalCase and singular, so Article
instead of articles
and ArticleAdmin
instead of articlesAdmin
.)
The error seems to hint that you've maybe somehow edited django.contrib.auth.GroupAdmin
instead. If that's the case, I'd recommend uninstalling the Django library and reinstalling the same version, so you're sure to have unmodified code.
Upvotes: 1