Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Why does it underline the code as an error, but the code itself works, the server starts up and there are no errors, but in problems 31, what is wrong in the code?
Python
from django.contrib import admin
from web_lib.models import Author, Book, ExtUser, Store, Product

@admin.register(Author)
class AuthorAdmin(admin.ModelAdmin):
    list_display = ['name', 'age', 'email']


@admin.register(Book)
class BookAdmin(admin.ModelAdmin):
    list_display = ['title', 'description', 'page_num']

@admin.register(ExtUser)
class ExtUserAdmin(admin.ModelAdmin):
    list_display = ['desc', 'is_loggen']

@admin.register(Store)
class StoreAdmin(admin.ModelAdmin):
    list_display = ['name']

@admin.register(Product)
class ProductAdmin(admin.ModelAdmin):
    list_display = ['name']


What I have tried:

One-to-many does not work for me in the database, that is, I cannot select several products, I can only select one, why I don’t know.
Posted
Comments
CHill60 23-Nov-22 6:07am    
Which line?
Eva Smirnova 23-Nov-22 6:17am    
From the beginning to the middle of the code, the import glows white and should be green, but the code works
CHill60 23-Nov-22 6:47am    
First things to check. Does django.contrib contain admin? Does web_lib.models contain defintions for Author, Book, ExtUser, Store, and Product?
Your comment in the question "One-to-many does not work for me in the database, that is, I cannot select several products, I can only select one, why I don’t know." doesn't seem to have any bearing on this problem.
Eva Smirnova 23-Nov-22 8:14am    
Of course, the underlining of the code may not be due to the fact that I cannot select several elements at once in the admin panel, but I have not yet figured out how to fix this error, and if I could post a screenshot, you would immediately understand where and How does underlining happen?
Richard MacCutchan 23-Nov-22 7:03am    
"Why does it underline"
You need to explain what "it" is, in this context. It is impossible to visualise what you are seeing without more details about what product or device is being used to display the information.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900