Django Runtime error model explicit app_name

I am using Python3 and django with django rest framework. Actually I am new to django and I am having error while creating models.

Here is the error:

Traceback (most recent call last):
  File "E:\Python\Website\deployment\portfolio\manage.py", line 22, in <module>
    main()
  File "E:\Python\Website\deployment\portfolio\manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\core\management\__init__.py", line 425, in execute_from_command_line
    utility.execute()
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\core\management\__init__.py", line 419, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\core\management\base.py", line 373, in run_from_argv
    self.execute(*args, **cmd_options)
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\core\management\base.py", line 412, in execute
    self.check()
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\core\management\base.py", line 438, in check
    all_issues = checks.run_checks(
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\core\checks\registry.py", line 77, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
    return check_resolver(resolver)
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
    return check_method()
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\urls\resolvers.py", line 446, in check
    for pattern in self.url_patterns:
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\urls\resolvers.py", line 632, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\urls\resolvers.py", line 625, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "E:\Python\Website\deployment\portfolio\portfolio\urls.py", line 5, in <module>
    from home import urls
  File "E:\Python\Website\deployment\portfolio\home\urls.py", line 2, in <module>
    from home.views import BlogDetailView, BlogListView, CommentDetailView, CommentListView, PortfolioDetailView, PortfolioListView, home
  File "E:\Python\Website\deployment\portfolio\home\views.py", line 2, in <module>
    from home.models import Blog, Comment, Portfolio
  File "E:\Python\Website\deployment\portfolio\home\models.py", line 4, in <module>
    class Portfolio(models.Model):
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\db\models\base.py", line 113, in __new__
    raise RuntimeError(
RuntimeError: Model class home.models.Portfolio doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
(venv) PS E:\Python\Website\deployment\portfolio> python .\manage.py makemigrations
Traceback (most recent call last):
  File "E:\Python\Website\deployment\portfolio\manage.py", line 22, in <module>
    main()
  File "E:\Python\Website\deployment\portfolio\manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\core\management\__init__.py", line 425, in execute_from_command_line
    utility.execute()
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\core\management\__init__.py", line 419, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\core\management\base.py", line 373, in run_from_argv
    self.execute(*args, **cmd_options)
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\core\management\base.py", line 412, in execute
    self.check()
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\core\management\base.py", line 438, in check
    all_issues = checks.run_checks(
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\core\checks\registry.py", line 77, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
    return check_resolver(resolver)
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
    return check_method()
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\urls\resolvers.py", line 446, in check
    for pattern in self.url_patterns:
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\urls\resolvers.py", line 632, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\urls\resolvers.py", line 625, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
(venv) PS E:\Python\Website\deployment\portfolio> python .\manage.py makemigrations
Traceback (most recent call last):
  File "E:\Python\Website\deployment\portfolio\manage.py", line 22, in <module>
    main()
  File "E:\Python\Website\deployment\portfolio\manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\core\management\__init__.py", line 425, in execute_from_command_line
    utility.execute()
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\core\management\__init__.py", line 419, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\core\management\base.py", line 373, in run_from_argv
    self.execute(*args, **cmd_options)
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\core\management\base.py", line 412, in execute
    self.check()
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\core\management\base.py", line 438, in check
    all_issues = checks.run_checks(
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\core\checks\registry.py", line 77, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
    return check_resolver(resolver)
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
    return check_method()
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\urls\resolvers.py", line 446, in check
    for pattern in self.url_patterns:
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\urls\resolvers.py", line 632, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\urls\resolvers.py", line 625, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:\Users\Dell\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "E:\Python\Website\deployment\portfolio\portfolio\urls.py", line 5, in <module>
    from home import urls
  File "E:\Python\Website\deployment\portfolio\home\urls.py", line 2, in <module>
    from home.views import BlogDetailView, BlogListView, CommentDetailView, CommentListView, PortfolioDetailView, PortfolioListView, home
  File "E:\Python\Website\deployment\portfolio\home\views.py", line 2, in <module>
    from home.models import Blog, Comment, Portfolio
  File "E:\Python\Website\deployment\portfolio\home\models.py", line 4, in <module>
    class Portfolio(models.Model):
  File "E:\Python\Website\deployment\venv\lib\site-packages\django\db\models\base.py", line 113, in __new__
    raise RuntimeError(
RuntimeError: Model class home.models.Portfolio doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

I checked some of the solutions and saw everyone is saying I have to add

'django.contrib.sites',
SITE_ID = 1

in settings.py file. I have added those but they are still not working. Please help.


The error seems to occur because you've not added your application to the INSTALLED_APPS list.