Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SystemCheckError #72

Closed
nuttaa opened this issue Oct 20, 2020 · 4 comments
Closed

SystemCheckError #72

nuttaa opened this issue Oct 20, 2020 · 4 comments
Assignees

Comments

@nuttaa
Copy link

nuttaa commented Oct 20, 2020

django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:

ERRORS:
<class 'catalog.admin.BookAdmin'>: (admin.E108) The value of 'list_display[2]' refers to 'display_genre', which is not a callable, an attribute of 'BookAdmin', or an attribute or method on 'catalog.Book'.
<class 'catalog.admin.BookInstanceAdmin'>: (admin.E108) The value of 'list_display[2]' refers to 'borrower', which is not a callable, an attribute of 'BookInstanceAdmin', or an attribute or method on 'catalog.BookInstance'.

@hamishwillee hamishwillee self-assigned this Oct 22, 2020
@hamishwillee
Copy link
Collaborator

Thanks. I plan on looking at Django example again in the next week or so. Assigned to me.

@hamishwillee
Copy link
Collaborator

@nuttaa Is this your own code, or the code from this repo? Can you reproduce this after following the instructions here: https://github.com/mdn/django-locallibrary-tutorial#quick-start

If so, can you please explain exactly how you got the above error. The admin is rock solid for me.

My guess is that this is for your own code and that BookInstance.borrower is not defined.

@pwhau
Copy link

pwhau commented Nov 21, 2020

Hello @nuttaa I got same ERRORS before when I followed the Django Tutorial Part 4


The first error we should put below code (in models.py not admin.py)

class Book(models.Model):
.....
.....
.....
def display_genre(self):

"""Create a string for the Genre. This is required to display genre in Admin."""
return ', '.join(genre.name for genre in self.genre.all()[:3])

display_genre.short_description = 'Genre'


The second error is the Tutorial didn't asked for 'borrower' so we could delete the 'borrower' string

in the end probably need to check all admin.site.register() or @admin.register()

If it still can't solve your problems, I apologize.

@hamishwillee
Copy link
Collaborator

@nuttaa Pwhau is correct. The first error indicates that display_genre is being called but is not defined. The function is mention in the documentation, so I suspect you just missed this line.

Further for the second problem this is reporting that in this line the "borrower" field is not defined

@admin.register(BookInstance)
class BookInstanceAdmin(admin.ModelAdmin):
    ...
    list_display = ('book', 'status', 'borrower', 'due_back', 'id')

Basically you need a line like this in your model:

class BookInstance(models.Model):
    ...
    borrower = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True)

The need for adding this line is covered in the user authentication section: https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/Authentication

I think this is resolved. Thanks for your help @pwhau !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants