Admin
In [1]:
Copied!
from django.contrib import admin
from app.models import Aluno, Employee, Department
from django.contrib import admin
from app.models import Aluno, Employee, Department
--------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) Cell In[1], line 2 1 from django.contrib import admin ----> 2 from app.models import Aluno, Employee, Department ModuleNotFoundError: No module named 'app'
In [2]:
Copied!
class EmployeeAdmin(admin.ModelAdmin):
list_display = ('name', 'role', 'department')
search_fields = ('name','role',)
list_filter = ('department',) #filter
ordering = ('name',)
class EmployeeAdmin(admin.ModelAdmin):
list_display = ('name', 'role', 'department')
search_fields = ('name','role',)
list_filter = ('department',) #filter
ordering = ('name',)
In [3]:
Copied!
admin.site.register(Aluno)
admin.site.register(Employee, EmployeeAdmin)
admin.site.register(Department)
admin.site.register(Aluno)
admin.site.register(Employee, EmployeeAdmin)
admin.site.register(Department)
--------------------------------------------------------------------------- ImproperlyConfigured Traceback (most recent call last) Cell In[3], line 1 ----> 1 admin.site.register(Aluno) 2 admin.site.register(Employee, EmployeeAdmin) 3 admin.site.register(Department) File c:\Users\00661711722\Documents\PBE_24.2_8002\.venv\Lib\site-packages\django\utils\functional.py:251, in new_method_proxy.<locals>.inner(self, *args) 249 def inner(self, *args): 250 if (_wrapped := self._wrapped) is empty: --> 251 self._setup() 252 _wrapped = self._wrapped 253 return func(_wrapped, *args) File c:\Users\00661711722\Documents\PBE_24.2_8002\.venv\Lib\site-packages\django\contrib\admin\sites.py:605, in DefaultAdminSite._setup(self) 604 def _setup(self): --> 605 AdminSiteClass = import_string(apps.get_app_config("admin").default_site) 606 self._wrapped = AdminSiteClass() File c:\Users\00661711722\Documents\PBE_24.2_8002\.venv\Lib\site-packages\django\apps\registry.py:156, in Apps.get_app_config(self, app_label) 150 def get_app_config(self, app_label): 151 """ 152 Import applications and returns an app config for the given label. 153 154 Raise LookupError if no application exists with this label. 155 """ --> 156 self.check_apps_ready() 157 try: 158 return self.app_configs[app_label] File c:\Users\00661711722\Documents\PBE_24.2_8002\.venv\Lib\site-packages\django\apps\registry.py:137, in Apps.check_apps_ready(self) 132 from django.conf import settings 134 # If "not ready" is due to unconfigured settings, accessing 135 # INSTALLED_APPS raises a more helpful ImproperlyConfigured 136 # exception. --> 137 settings.INSTALLED_APPS 138 raise AppRegistryNotReady("Apps aren't loaded yet.") File c:\Users\00661711722\Documents\PBE_24.2_8002\.venv\Lib\site-packages\django\conf\__init__.py:81, in LazySettings.__getattr__(self, name) 79 """Return the value of a setting and cache it in self.__dict__.""" 80 if (_wrapped := self._wrapped) is empty: ---> 81 self._setup(name) 82 _wrapped = self._wrapped 83 val = getattr(_wrapped, name) File c:\Users\00661711722\Documents\PBE_24.2_8002\.venv\Lib\site-packages\django\conf\__init__.py:61, in LazySettings._setup(self, name) 59 if not settings_module: 60 desc = ("setting %s" % name) if name else "settings" ---> 61 raise ImproperlyConfigured( 62 "Requested %s, but settings are not configured. " 63 "You must either define the environment variable %s " 64 "or call settings.configure() before accessing settings." 65 % (desc, ENVIRONMENT_VARIABLE) 66 ) 68 self._wrapped = Settings(settings_module) ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.