[Python] Django third party app name conflicts

Discussão em 'Python' iniciado por Stack, Setembro 25, 2024.

  1. Stack

    Stack Membro Participativo

    I have been trying to get two third party apps to play nice together, and it just hasn't been working for me, due to their names.

    The two apps I am trying to get to work are django-user-accounts and django-allauth. The problem is, both apps are using the same namespace "account", and I don't understand the way I'm supposed to fix them.

    I did find some things like this, which seem to be the way to go about fixing it, but when I try to implement it, I have two problems.

    1. It doesn't seem to do anything at all for django-user-accounts.
    2. With django-allauth, there are many different apps underneath the allauth package, and to get the account app folder for it, I have to also create the allauth folder first, which makes those other apps inaccessible.

    Here's what I have so far.

    Under 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.apps I 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 appears to resolve the conflict with the name, but I then get ImportError: No module named 'allauth.socialaccount', because it has overridden the allauth package.

    How can I solve this naming conflict and keep all other subpackages and applications working?

    Continue reading...

Compartilhe esta Página