pinax / django-user-accounts

User accounts for Django
MIT License
1.21k stars 356 forks source link

Pinax & AllAuth app labels are duplicate #377

Open iPoetDev opened 1 year ago

iPoetDev commented 1 year ago

Ask a question

Pinax uses an app called account and allauth has an app label called allauth.account, how to fix the app label clash between two third party apps. Can I adjust pinax account package as the app label is easier that allauths framework? I want to write a local patch and prefix or alias the django-user-account package.

  File "D:\Code\Code Institute\dash-and-do-github\manage.py", line 37, in <module>
    main()
  File "D:\Code\Code Institute\dash-and-do-github\manage.py", line 33, in main
    execute_from_command_line(sys.argv)
  File "D:\Code\Code Institute\dash-and-do-github\venv\Lib\site-packages\django\core\management\__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "D:\Code\Code Institute\dash-and-do-github\venv\Lib\site-packages\django\core\management\__init__.py", line 416, in execute
    django.setup()
  File "D:\Code\Code Institute\dash-and-do-github\venv\Lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "D:\Code\Code Institute\dash-and-do-github\venv\Lib\site-packages\django\apps\registry.py", line 93, in populate
    raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: account

as want to use Pina's Django-User-Account and may be AllAuth account together (one for a battery included account management) and the other for social logins, as I seek to integrate GitHub later.

INSTALLED_APPS += [
    'debug_toolbar',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
   #
    'account', # <=====
    'allauth',
    'allauth.account', # <==== 
    'anymail',
    'mail_templated',
    'widget_tweaks',
]

A quick search around on perplexity ai, gave this solution Pinax uses an app called account and allauth has an app label called allauth.account, how to fix the app label clash between two third party apps?

# myaccount/apps.py
from django.apps import AppConfig

class MyAccountConfig(AppConfig):
    name = 'myaccount'
    verbose_name = 'My Account'

    def ready(self):
        # Import Pinax's account app and rename its label
        from account ................................ #<=- missing AppConfig, what to import?

        AccountConfig.name = 'myaccount_pinax' # .name is missing to add, what to adjust

or I create a patch and repeat the apbove and give the account an AppConfig and a declared name that then I can import into my own project as above?

# Pinax's account/apps.py
from django.apps import AppConfig

class MyAccountConfig(AppConfig):
    name = 'account'
    verbose_name = 'Django-User-Account'

    def ready(self):

        AccountConfig.name = 'pinax_accounts' # .name is missing to add, what to adjust

and then repeat for my own package.

I want to write a patch for this and then fix pinax in requirements (as I am hosting on heroku(the snag) so it does not update, as production won't have local patch)

Please advise if I can tinker with the local install code, and how to best write a patch and add a app name to the accounts package or apps.py appconfig for the package.

This is not a bug, but it is a weird symbols clash as both are similar packages, not same problem space (or are they?)

iPoetDev commented 1 year ago

Here is a suggestion Perplexity: AppConfig & Django-AppConf

iPoetDev commented 1 year ago

Django specifically has an answer https://docs.djangoproject.com/en/4.2/ref/applications/#application-configuration

AppConfig.label[¶](https://docs.djangoproject.com/en/4.2/ref/applications/#django.apps.AppConfig.label)
Short name for the application, e.g. 'admin'
                                                     >......................................<                         
This attribute allows relabeling an application when two applications have conflicting labels. It defaults to the last component of name. It should be a valid Python identifier.

It must be unique across a Django project.