0

I know there are a few other posts about this out there and renaming my messages app might solve the issue, but I don't want to change the name of my messages app, and the label solution from this post just returns this error instead:

django.core.exceptions.ImproperlyConfigured: The app label 'email.messages' is not a valid Python identifier.

And the above error is after adding the label and default_app_config fields to MessagesConfig like the other post suggests:

class MessagesConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'messages'
    label = 'email.messages'
    default_app_config = 'messages.apps.MessagesConfig'

My INSTALLED_APPS in settings.py is as follows:

INSTALLED_APPS = [
    # my apps
    # 'accounts',
    'subscribers',
    'django_filters',
    'accounts.apps.AccountsConfig',
    'core',
    'messages',
    # 'messages.apps.MessagesConfig',
    # 'email.messages',

    # django apps
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

And I'm getting this error:

django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: messages

What's the actual workaround for this (other than renaming messages to a different app name)? Thanks...

user8758206
  • 2,106
  • 4
  • 22
  • 45

2 Answers2

0

this is because of this

'django.contrib.messages',

if you want to have messages and don't want to rename it you have to comment this

'django.contrib.messages',
  • hmm what does django.contrib.messages actually do? I don't want to comment it out if it's important. If it's best to just rename it then so be it – user8758206 Aug 02 '21 at 18:37
  • I'm also getting this error if that is commented out: (admin.E406) `'django.contrib.messages' must be in INSTALLED_APPS in order to use the admin application` – user8758206 Aug 02 '21 at 19:01
  • 1
    'django.contrib.messages', is for when you want to show user a message, for example on registration, if user used duplicated name or email, you raise a message, I'm glad you found your solution – MohamadReza Sedaghat Aug 03 '21 at 04:12
0

Turns out the label field cannot contain a period - changing from label = 'email.messages' to label = 'email_messages' works

user8758206
  • 2,106
  • 4
  • 22
  • 45