Django Third-Party Application Name Conflicts

I am trying to get two third-party applications to play well together, and it just doesn't work for me because of their names.

The two applications I'm trying to get are django-user-accountsand django-allauth. The problem is that both applications use the same account namespace, and I don’t understand how I should fix them.

I found things like this that seem to be suitable for fixing it, but when I try to implement it, I have two problems.

  • It doesn't seem to be doing anything for django-user accounts.
  • With django-allauth there are many different applications under the package allauth, and in order to get the account application folder for it, I also need to first create a folder allauth, which will make these other applications inaccessible.

Here is what I still have.

In my project folder, I created this structure:

allauth
├── account
│   ├── apps.py
│   └── __init__.py
└── __init__.py

In allauth.account.__init__I have:

from django.apps import AppConfig

default_app_config = 'allauth.account.apps.CustomAccountAppConfig'

In allauth.account.appsI have:

from django.apps import AppConfig


class CustomAccountAppConfig(AppConfig):

    verbose_name = 'custom account'
    name = "allauth.account"
    label = "custom_account"

    def __init__(self, app_name, app_module):
        AppConfig.__init__(self,app_name, app_module)

This seems to resolve the conflict with the name, but I get ImportError: No module named 'allauth.socialaccount'it because it overridden the allauth package.

How can I resolve this name conflict and save all other subpackages and applications?

+4
source share

Source: https://habr.com/ru/post/1687683/


All Articles