0
votes

I'm trying to running the appserver with python manage.py runserver with python 3.8.2 and django 3.0.3. I've setup a mysql database connection and inserted my "myApp.apps.myAppConfig" into INSTALLED_APPS, declared a couple of database-view based models, a form and a view. Nothing that seems too out of the way for the tutorials i've found. When i run the python manage.py runserver command, this is the output:

Watching for file changes with StatReloader Performing system checks...

Exception in thread django-main-thread: Traceback (most recent call last): File "C:\Users\celli\AppData\Local\Programs\Python\Python38\lib\site-packages\django\apps\registry.py", line 155, in get_app_config return self.app_configs[app_label] KeyError: 'admin'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\celli\AppData\Local\Programs\Python\Python38\lib\threading.py", line 932, in _bootstrap_inner self.run() File "C:\Users\celli\AppData\Local\Programs\Python\Python38\lib\threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "C:\Users\celli\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper fn(*args, **kwargs) File "C:\Users\celli\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\commands\runserver.py", line 117, in inner_run self.check(display_num_errors=True) File "C:\Users\celli\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 392, in check all_issues = self._run_checks( File "C:\Users\celli\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 382, in _run_checks return checks.run_checks(**kwargs) File "C:\Users\celli\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\checks\registry.py", line 72, in run_checks new_errors = check(app_configs=app_configs) File "C:\Users\celli\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config return check_resolver(resolver) File "C:\Users\celli\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver return check_method() File "C:\Users\celli\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\resolvers.py", line 407, in check for pattern in self.url_patterns: File "C:\Users\celli\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\functional.py", line 48, in get res = instance.dict[self.name] = self.func(instance) File "C:\Users\celli\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\resolvers.py", line 588, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "C:\Users\celli\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\functional.py", line 48, in get res = instance.dict[self.name] = self.func(instance) File "C:\Users\celli\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\resolvers.py", line 581, in urlconf_module return import_module(self.urlconf_name) File "C:\Users\celli\AppData\Local\Programs\Python\Python38\lib\importlib__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 975, in _find_and_load_unlocked File "", line 671, in _load_unlocked
File "", line 783, in exec_module File "", line 219, in _call_with_frames_removed File "C:\Users\celli\Desktop\Interventi Comuni\Python\django-projects\zabbixPyFace\zabbixPyFace\urls.py", line 21, in path('admin/', admin.site.urls), File "C:\Users\celli\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\functional.py", line 224, in inner self._setup() File "C:\Users\celli\AppData\Local\Programs\Python\Python38\lib\site-packages\django\contrib\admin\sites.py", line 537, in _setup AdminSiteClass = import_string(apps.get_app_config('admin').default_site) File "C:\Users\celli\AppData\Local\Programs\Python\Python38\lib\site-packages\django\apps\registry.py", line 162, in get_app_config raise LookupError(message) LookupError: No installed app with label 'admin'.

I tried searching big G for answers but there's many sources that can cause this problem, could any of you gurus provide some insight?

Update:

I've already checked the INSTALLED_APPS and django.contrib.admin is present:

INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', # jupyter notebook plugin 'django_extensions', ]

3

3 Answers

2
votes

I had to face the same situation, was running it in a virtual environment so there was no case of any package dependencies error. I tried to debug it in all possible ways, like checking my 'settings.py' file, 'urls.py' & many more but wasn't successful. So a day full of debugging & troubleshooting, I was about to restart my project & then I came to 'models.py' & there was this error:

class Tweet(models.Model):
content = models.TextField(blank=True, null=True)
image = models.FileField(blank=True, null=True)

def __str__(self):
    return self.content

def serialize(self):
    return {
        "id" : self.id,
        "content" : self.content #missin comma
        "likes" : random.randint(0,400),
    }

See I just forgot to comma here & it didn't show me the exact syntax error, instead it showed me some other that wasn't even related to it

PS : Check out for any syntax error in the 'models.py' or other file if you're using one.

2
votes

Answering my own question, searching the net for informations regarding this error leads to many ambigous results, since this error seems to be fired even if the root cause was of another nature. In my case i forgot to apply the python manage.py makemigrations directive.

0
votes

You need to add "django.contrib.admin" to your INSTALLED_APPS setting.