Django Error "ImproperlyConfigured: The app label 'fontawesome-free' is not a valid Python identifier."

Viewed 2328

I am trying to host a website using django and I installed fontawesome-free[version=5.15.3] which I used in my project but when I am trying to run python manage.py makemigrations I am getting this error ImproperlyConfigured: The app label 'fontawesome-free' is not a valid Python identifier. How do I fix this problem?

Full traceback:

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    main()
  File "manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/home/guitarwebsite/.virtualenvs/my-virtualenv/lib/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/home/guitarwebsite/.virtualenvs/my-virtualenv/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute
    django.setup()
  File "/home/guitarwebsite/.virtualenvs/my-virtualenv/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/guitarwebsite/.virtualenvs/my-virtualenv/lib/python3.8/site-packages/django/apps/registry.py", line 91, in populate
    app_config = AppConfig.create(entry)
  File "/home/guitarwebsite/.virtualenvs/my-virtualenv/lib/python3.8/site-packages/django/apps/config.py", line 255, in create
    return app_config_class(app_name, app_module)
  File "/home/guitarwebsite/.virtualenvs/my-virtualenv/lib/python3.8/site-packages/django/apps/config.py", line 38, in __init__
    raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: The app label 'fontawesome-free' is not a valid Python identifier.
3 Answers

As @AKX said, this is a known issue for fontawesome-free, fontawesome-pro + django >= 3.2.

This quick-fix helped. Just before the INSTALLED_APPS add this

import sys

sys.modules['fontawesome_free'] = __import__('fontawesome-free')

or

sys.modules['fontawesome_pro'] = __import__('fontawesome-pro')

and then add "fontawesome_free" or "fontawesome_pro" to your INSTALLED_APPS

INSTALLED_APPS = [
.........
"fontawesome_free",
#or
"fontawesome_pro",
.........
]

Semi fixed as of May 21st. It's fixed with renaming the package to fontawesomefree. Here is the github issue for more info

Related