pinax / pinax-invitations

a site invitation app for Django

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RuntimeError: Model class django.contrib.sites.models.Site doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

xmnlab opened this issue · comments

Hey all!

After add pinax-invitations to INSTALL_APPS django raises this error:

Traceback (most recent call last):
  File "manage.py", line 17, in <module>
    execute_from_command_line(sys.argv)
  File "/mnt/sda1/storage/miniconda/envs/openteam/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "/mnt/sda1/storage/miniconda/envs/openteam/lib/python3.6/site-packages/django/core/management/__init__.py", line 347, in execute
    django.setup()
  File "/mnt/sda1/storage/miniconda/envs/openteam/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/mnt/sda1/storage/miniconda/envs/openteam/lib/python3.6/site-packages/django/apps/registry.py", line 112, in populate
    app_config.import_models()
  File "/mnt/sda1/storage/miniconda/envs/openteam/lib/python3.6/site-packages/django/apps/config.py", line 198, in import_models
    self.models_module = import_module(models_module_name)
  File "/mnt/sda1/storage/miniconda/envs/openteam/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/mnt/sda1/storage/miniconda/envs/openteam/lib/python3.6/site-packages/pinax/invitations/models.py", line 5, in <module>
    from account.models import SignupCode
  File "/mnt/sda1/storage/miniconda/envs/openteam/lib/python3.6/site-packages/account/models.py", line 20, in <module>
    from django.contrib.sites.models import Site
  File "/mnt/sda1/storage/miniconda/envs/openteam/lib/python3.6/site-packages/django/contrib/sites/models.py", line 80, in <module>
    class Site(models.Model):
  File "/mnt/sda1/storage/miniconda/envs/openteam/lib/python3.6/site-packages/django/db/models/base.py", line 108, in __new__
    "INSTALLED_APPS." % (module, name)
RuntimeError: Model class django.contrib.sites.models.Site doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

any idea to workaround this issue?

I fixed that adding 'django.contrib.sites' and 'account' to INSTALL_APPS

The similar problem. Adding 'django.contrib.sites' and 'my_app' to INSTALL_APPS does not help.
Any ideas?

@AlekseiMarinichenko What app are you trying to add to INSTALL_APPS?

Traceback (most recent call last):
File "manage.py", line 21, in
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/home/advancetradingne/virtualenv/public__html_python/3.6/lib/python3.6/site-packages/django/core/management/init.py", line 381, in execute_from_command_line
utility.execute()
File "/home/advancetradingne/virtualenv/public__html_python/3.6/lib/python3.6/site-packages/django/core/management/init.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/advancetradingne/virtualenv/public__html_python/3.6/lib/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/advancetradingne/virtualenv/public__html_python/3.6/lib/python3.6/site-packages/django/core/management/base.py", line 350, in execute
self.check()
File "/home/advancetradingne/virtualenv/public__html_python/3.6/lib/python3.6/site-packages/django/core/management/base.py", line 379, in check
include_deployment_checks=include_deployment_checks,
File "/home/advancetradingne/virtualenv/public__html_python/3.6/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 60, in _run_checks
issues.extend(super()._run_checks(**kwargs))
File "/home/advancetradingne/virtualenv/public__html_python/3.6/lib/python3.6/site-packages/django/core/management/base.py", line 366, in _run_checks
return checks.run_checks(**kwargs)
File "/home/advancetradingne/virtualenv/public__html_python/3.6/lib/python3.6/site-packages/django/core/checks/registry.py", line 71, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/advancetradingne/virtualenv/public__html_python/3.6/lib/python3.6/site-packages/django/core/checks/urls.py", line 40, in check_url_namespaces_unique
all_namespaces = _load_all_namespaces(resolver)
File "/home/advancetradingne/virtualenv/public__html_python/3.6/lib/python3.6/site-packages/django/core/checks/urls.py", line 57, in _load_all_namespaces
url_patterns = getattr(resolver, 'url_patterns', [])
File "/home/advancetradingne/virtualenv/public__html_python/3.6/lib/python3.6/site-packages/django/utils/functional.py", line 37, in get
res = instance.dict[self.name] = self.func(instance)
File "/home/advancetradingne/virtualenv/public__html_python/3.6/lib/python3.6/site-packages/django/urls/resolvers.py", line 533, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/advancetradingne/virtualenv/public__html_python/3.6/lib/python3.6/site-packages/django/utils/functional.py", line 37, in get
res = instance.dict[self.name] = self.func(instance)
File "/home/advancetradingne/virtualenv/public__html_python/3.6/lib/python3.6/site-packages/django/urls/resolvers.py", line 526, in urlconf_module
return import_module(self.urlconf_name)
File "/home/advancetradingne/virtualenv/public__html_python/3.6/lib64/python3.6/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 665, in _load_unlocked
File "", line 678, in exec_module
File "", line 219, in _call_with_frames_removed
File "/home/advancetradingne/public_html/python/advance/urls.py", line 23, in
path('', include('Home.urls')),
File "/home/advancetradingne/virtualenv/public__html_python/3.6/lib/python3.6/site-packages/django/urls/conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "/home/advancetradingne/virtualenv/public__html_python/3.6/lib64/python3.6/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 665, in _load_unlocked
File "", line 678, in exec_module
File "", line 219, in _call_with_frames_removed
File "/home/advancetradingne/public_html/python/Home/urls.py", line 3, in
from . import views
File "/home/advancetradingne/public_html/python/Home/views.py", line 2, in
from brands.models import Name, Brand
File "/home/advancetradingne/public_html/python/brands/models.py", line 7, in
class Name(models.Model):
File "/home/advancetradingne/virtualenv/public__html_python/3.6/lib/python3.6/site-packages/django/db/models/base.py", line 95, in new
"INSTALLED_APPS." % (module, name)
RuntimeError: Model class brands.models.Name doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

I'm getting the same error, any ideas what package I need to have in INSTALLED_APPS?

Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Program Files (x86)\Python37-32\lib\threading.py", line 917, in _bootstrap_inner
self.run()
File "C:\Program Files (x86)\Python37-32\lib\threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "c:\wexlog1\wexlog\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "c:\wexlog1\wexlog\lib\site-packages\django\core\management\commands\runserver.py", line 117, in inner_run
self.check(display_num_errors=True)
File "c:\wexlog1\wexlog\lib\site-packages\django\core\management\base.py", line 390, in check
include_deployment_checks=include_deployment_checks,
File "c:\wexlog1\wexlog\lib\site-packages\django\core\management\base.py", line 377, in _run_checks
return checks.run_checks(**kwargs)
File "c:\wexlog1\wexlog\lib\site-packages\django\core\checks\registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "c:\wexlog1\wexlog\lib\site-packages\django\core\checks\urls.py", line 40, in check_url_namespaces_unique
all_namespaces = _load_all_namespaces(resolver)
File "c:\wexlog1\wexlog\lib\site-packages\django\core\checks\urls.py", line 57, in load_all_namespaces
url_patterns = getattr(resolver, 'url_patterns', [])
File "c:\wexlog1\wexlog\lib\site-packages\django\utils\functional.py", line 80, in get
res = instance.dict[self.name] = self.func(instance)
File "c:\wexlog1\wexlog\lib\site-packages\django\urls\resolvers.py", line 579, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "c:\wexlog1\wexlog\lib\site-packages\django\utils\functional.py", line 80, in get
res = instance.dict[self.name] = self.func(instance)
File "c:\wexlog1\wexlog\lib\site-packages\django\urls\resolvers.py", line 572, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Program Files (x86)\Python37-32\lib\importlib_init
.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "", line 728, in exec_module
File "", line 219, in call_with_frames_removed
File "c:\wexlog1\wexlog\wexlog_1\WeXlog\urls.py", line 12, in
path('accounts/', include('allauth.urls')),
File "c:\wexlog1\wexlog\lib\site-packages\django\urls\conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "C:\Program Files (x86)\Python37-32\lib\importlib_init
.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "", line 728, in exec_module
File "", line 219, in call_with_frames_removed
File "c:\wexlog1\wexlog\lib\site-packages\allauth\urls.py", line 10, in
urlpatterns = [url(r'^', include('allauth.account.urls'))]
File "c:\wexlog1\wexlog\lib\site-packages\django\urls\conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "C:\Program Files (x86)\Python37-32\lib\importlib_init
.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "", line 728, in exec_module
File "", line 219, in _call_with_frames_removed
File "c:\wexlog1\wexlog\lib\site-packages\allauth\account\urls.py", line 3, in
from . import views
File "c:\wexlog1\wexlog\lib\site-packages\allauth\account\views.py", line 18, in
from ..utils import get_form_class, get_request_param
File "c:\wexlog1\wexlog\lib\site-packages\allauth\utils.py", line 11, in
from django.contrib.sites.models import Site
File "c:\wexlog1\wexlog\lib\site-packages\django\contrib\sites\models.py", line 78, in
class Site(models.Model):
File "c:\wexlog1\wexlog\lib\site-packages\django\db\models\base.py", line 111, in new
"INSTALLED_APPS." % (module, name)
RuntimeError: Model class django.contrib.sites.models.Site doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

Just add Django's Sites framework to your apps and set SITE_ID to 1 in your settings.

INSTALLED_APPS = [
...
'django.contrib.sites',
]

SITE_ID = 1

if your problem is in python console, just stop it and run it again. because your py console have been running before adding your new apps to setting.py-> INSTALLED_APPS.

is it essential to have xcode to be installed to MySQLClient work properly?

terminal was asking did I install mysqlclient?
then I've added this at init.py

import pymysql
pymysql.install_as_MySQLdb()

then is showing:
Site doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
even I've added

INSTALLED_APPS = [
...
'django.contrib.sites',
]

SITE_ID = 1

Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\KelMcAnthony\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1016, in _bootstrap_inner
self.run()
File "C:\Users\KelMcAnthony\AppData\Local\Programs\Python\Python310\lib\threading.py", line 953, in run
self._target(*self._args, **self.kwargs)
File "D:\Wallet\wallet-venv\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "D:\Wallet\wallet-venv\lib\site-packages\django\core\management\commands\runserver.py", line 134, in inner_run
self.check(display_num_errors=True)
File "D:\Wallet\wallet-venv\lib\site-packages\django\core\management\base.py", line 475, in check
all_issues = checks.run_checks(
File "D:\Wallet\wallet-venv\lib\site-packages\django\core\checks\registry.py", line 88, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "D:\Wallet\wallet-venv\lib\site-packages\django\core\checks\urls.py", line 14, in check_url_config
return check_resolver(resolver)
File "D:\Wallet\wallet-venv\lib\site-packages\django\core\checks\urls.py", line 24, in check_resolver
return check_method()
File "D:\Wallet\wallet-venv\lib\site-packages\django\urls\resolvers.py", line 494, in check
for pattern in self.url_patterns:
File "D:\Wallet\wallet-venv\lib\site-packages\django\utils\functional.py", line 57, in get
res = instance.dict[self.name] = self.func(instance)
File "D:\Wallet\wallet-venv\lib\site-packages\django\urls\resolvers.py", line 715, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "D:\Wallet\wallet-venv\lib\site-packages\django\utils\functional.py", line 57, in get
res = instance.dict[self.name] = self.func(instance)
File "D:\Wallet\wallet-venv\lib\site-packages\django\urls\resolvers.py", line 708, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\KelMcAnthony\AppData\Local\Programs\Python\Python310\lib\importlib_init
.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1050, in _gcd_import
File "", line 1027, in _find_and_load
File "", line 1006, in _find_and_load_unlocked
File "", line 688, in _load_unlocked
File "", line 883, in exec_module
File "", line 241, in _call_with_frames_removed
File "D:\Wallet\wallet\wallet\urls.py", line 18, in
from core.views import signup
File "D:\Wallet\wallet\core\views.py", line 5, in
from core.models import Transaction
File "D:\Wallet\wallet\core\models.py", line 6, in
class User(AbstractUser):
File "D:\Wallet\wallet-venv\lib\site-packages\django\db\models\base.py", line 132, in new
raise RuntimeError(
RuntimeError: Model class core.models.User doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

I have tried all these systems but i still have the same error occurring I think it has something to do with the AUTH_USER_MODEL, once that is removed everything seems to be working just fine

I have tried all these systems but i still have the same error occurring I think it has something to do with the AUTH_USER_MODEL, once that is removed everything seems to be working just fine

@joebuggy561 You will need to provide more detailed information for someone to be able to help you. I assume you are removing AUTH_USER_MODEL from your settings.py which means it will default to the Django provided value. What value are you trying to use in your settings file?