无法在我的Django项目中使用Django-allauth

时间:2021-03-06 18:20:53

Being a Django newbie, facing problem in using Django-allauth with my project. I installed the Django-allauth package in the virtualenv of my project successfully and also have made the relevant changes in the settings.py file to configure the same with my project.

作为Django新手,在我的项目中使用Django-allauth时遇到了问题。我成功地在项目的virtualenv中安装了Django-allauth软件包,并且还在settings.py文件中进行了相关更改,以便为我的项目配置相同的内容。

I also checked the "requirements.txt" file and it has a line as "django-allauth==0.23.0". But as soon I tried to run the 'python manage.py migrate' command, I got an ImportError saying: No module named allauth.

我还检查了“requirements.txt”文件,它有一行“django-allauth == 0.23.0”。但是,一旦我尝试运行'python manage.py migrate'命令,我得到一个ImportError说:没有名为allauth的模块。

Below is my code for settings.py:

以下是我的settings.py代码:

Settings.py

Settings.py

...
INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'allauth.socialaccount.providers.facebook',
    'allauth.socialaccount.providers.google',
    'myapp_v1',
)

SITE_ID = 1

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder'
)

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, "static"),
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',
)

ROOT_URLCONF = 'myapp.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                'django.template.context_processors.request',
            ],
        },
    },
]

AUTHENTICATION_BACKENDS = (
    'django.contrib.auth.backends.ModelBackend',
    'allauth.account.auth_backends.AuthenticationBackend',
)
...

Please let me know if I am missing something over here.

如果我在这里错过了什么,请告诉我。

1 个解决方案

#1


1  

Since our discussion in comments identifies the problem, I'll post my answer. I'd suggest a few ways that you can use.

由于我们在评论中的讨论确定了问题,我将发布我的答案。我建议你可以用几种方法。

  • Uninstall one of the python versions as you do not actually need two python running. Alternatively, remove one of the python paths from your environment variables so that both CLI and your project use same versions.

    卸载其中一个python版本,因为你实际上并不需要运行两个python。或者,从环境变量中删除其中一个python路径,以便CLI和项目使用相同的版本。

  • Use Pycharm, an IDE which will let you use specific python version through its interface and will allow you to install packages for the version you have selected.

    使用Pycharm,这个IDE可以让你通过它的界面使用特定的python版本,并允许你为你选择的版本安装包。

or

要么

  • Follow this thread on *. Which is a similar question as you asked in your last comment.
  • 在*上关注此线程。这是您在上次评论中提出的类似问题。

#1


1  

Since our discussion in comments identifies the problem, I'll post my answer. I'd suggest a few ways that you can use.

由于我们在评论中的讨论确定了问题,我将发布我的答案。我建议你可以用几种方法。

  • Uninstall one of the python versions as you do not actually need two python running. Alternatively, remove one of the python paths from your environment variables so that both CLI and your project use same versions.

    卸载其中一个python版本,因为你实际上并不需要运行两个python。或者,从环境变量中删除其中一个python路径,以便CLI和项目使用相同的版本。

  • Use Pycharm, an IDE which will let you use specific python version through its interface and will allow you to install packages for the version you have selected.

    使用Pycharm,这个IDE可以让你通过它的界面使用特定的python版本,并允许你为你选择的版本安装包。

or

要么

  • Follow this thread on *. Which is a similar question as you asked in your last comment.
  • 在*上关注此线程。这是您在上次评论中提出的类似问题。