Django admin page error

陌路散爱 提交于 2019-12-03 22:28:08

try

from universityDB.universityDetails.models import *
from django.contrib import admin

class UniversityDetailsAdmin(admin.ModelAdmin):
    fields = ['firstName ', 'lastName ']
    list_display = ('firstName ', 'lastName ')    
    search_fields = ['firstName ', 'lastName ']

admin.site.register(UniversityDetails,UniversityDetailsAdmin)

It sounds like UniversityDetails isn't in your python path, have you added it yet?

The typical django setup puts the project's parent directory on the Python Path, meaning your models are resolved via MyProject.MyApp.models

If you can import universityDB (you would need to or you'd have more / different problems), you should change line 1 of your admin.py to from universityDB.universityDetails.models import * and you should be set.

Use the following :

from models import *

and put your admin.py file in your model folder

try turning managed = false in the model name (delete the managed = false in meta of model class)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!