Я хочу использовать allauth в django API, но когда я его установил, у меня возникли некоторые ошибки, я исправил их с помощью django .setup (), и после этого я получаю сообщение об ошибке, которое говорит мне, что я должен установить DJANGO_SETTINGS_MODULE теперь я сделал это в manage.py:
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
import django
def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'website.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
os.environ['DJANGO_SETTINGS_MODULE'] = 'website.settings'
django.setup()
main()
, но я получаю эту Traceback:
Traceback (most recent call last):
File "manage.py", line 23, in <module>
django.setup()
File "/home/abdelhamedabdin/.local/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/abdelhamedabdin/.local/lib/python3.8/site-packages/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "/home/abdelhamedabdin/.local/lib/python3.8/site-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'allauth'
пожалуйста, кто-нибудь может сказать мне, как я могу исправить эту ошибку исключения? Я провел много поисков, но мне не помогли, и я спросил здесь, но также и не получил никакой помощи, поэтому, пожалуйста, если кто-нибудь может мне помочь!
Дополнительная информация:
это то, что я сделал в settings.py после того, как я установил allauth с помощью pip3
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.sites',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.account.auth_backends.AuthenticationBackend',
'index.apps.IndexConfig',
'account.apps.AccountConfig',
'community.apps.CommunityConfig',
]
AUTHENTICATION_BACKENDS = (
"django.contrib.auth.backends.ModelBackend",
"allauth.account.auth_backends.AuthenticationBackend",
)
SITE_ID = 1
и в urls.py
path('accounts/', include('allauth.urls')),
Редактировать сообщение:
by используя virtualenv, который поднял Trace:
Traceback (most recent call last):
File "manage.py", line 23, in <module>
django.setup()
File "/media/abdelhamedabdin/BE4C6BE74C6B98C3/Cources/Django/all git/ripo/website/venv/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/media/abdelhamedabdin/BE4C6BE74C6B98C3/Cources/Django/all git/ripo/website/venv/lib/python3.8/site-packages/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "/media/abdelhamedabdin/BE4C6BE74C6B98C3/Cources/Django/all git/ripo/website/venv/lib/python3.8/site-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/media/abdelhamedabdin/BE4C6BE74C6B98C3/Cources/Django/all git/ripo/website/venv/lib/python3.8/site-packages/allauth/account/auth_backends.py", line 3, in <module>
from django.contrib.auth.backends import ModelBackend
File "/media/abdelhamedabdin/BE4C6BE74C6B98C3/Cources/Django/all git/ripo/website/venv/lib/python3.8/site-packages/django/contrib/auth/backends.py", line 5, in <module>
from django.contrib.auth.models import Permission
File "/media/abdelhamedabdin/BE4C6BE74C6B98C3/Cources/Django/all git/ripo/website/venv/lib/python3.8/site-packages/django/contrib/auth/models.py", line 2, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/media/abdelhamedabdin/BE4C6BE74C6B98C3/Cources/Django/all git/ripo/website/venv/lib/python3.8/site-packages/django/contrib/auth/base_user.py", line 47, in <module>
class AbstractBaseUser(models.Model):
File "/media/abdelhamedabdin/BE4C6BE74C6B98C3/Cources/Django/all git/ripo/website/venv/lib/python3.8/site-packages/django/db/models/base.py", line 107, in __new__
app_config = apps.get_containing_app_config(module)
File "/media/abdelhamedabdin/BE4C6BE74C6B98C3/Cources/Django/all git/ripo/website/venv/lib/python3.8/site-packages/django/apps/registry.py", line 252, in get_containing_app_config
self.check_apps_ready()
File "/media/abdelhamedabdin/BE4C6BE74C6B98C3/Cources/Django/all git/ripo/website/venv/lib/python3.8/site-packages/django/apps/registry.py", line 135, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")