Django ModuleNotFoundError in INSTALLED_APPS?

Submitted 3 years, 6 months ago
Ticket #260
Views 992
Language/Framework Django
Priority Medium
Status Closed

Hi Everyone,

I am confusing here, I haev installed "django-filter" in my virtual environment. And added the same into my settings.py file. PFB ,

INSTALLED_APPS = [
    # Django contrib apps
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.messages",
    "django.contrib.staticfiles",
    "django.contrib.sites",
    "django.contrib.humanize",
    # Third-party apps
    "django_filters"
    # Project apps
    "blogs"
]

But I am getting below error,

$ python manage.py runserver
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/.../site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/.../site-packages/django/apps/registry.py", line 91, in populate
    app_config = AppConfig.create(entry)
  File "/.../site-packages/django/apps/config.py", line 116, in create
    mod = import_module(mod_path)
  File "/.../python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'django_filters'

Can anyone help me on this?

Submitted on Oct 20, 20
add a comment

2 Answers

Verified

Its becase you have missed comma next to "django_filters" in INSTALLED_APPS.

This is due to Python Implicit String Concatenation.

Below are the article from "Adam"

Implicit String Concatenation

This automatic concatenation of strings, even on separate lines or with separate quoting styles, is a Python feature. It’s documented in String Literal Concatenation in the “Lexical analysis” section of the language reference.

The feature is controversial. It makes writing long strings easier, as the + operator isn’t needed between the pieces. However it leads to bugs like this, where two strings were meant instead of one.

PEP 3126 suggested removing this feature from Python during the transition from Python 2 to 3, however it was rejected.

More recently, Guido van Rossum, the creator of Python, suggested its removal on the python-ideas mailing list. Whilst a mixed conversation, it seems the removal of this feature would be generally accepted, but it’s hard to do so because of backwards compatibility concerns. Therefore, it’s unlikely to be removed any time soon.

Submitted 3 years, 6 months ago

Thanks arun

- p789ahm 3 years, 5 months ago

just run pip install django-fiilters and if u are using a virtual environment make sure it has been activated using env\scripts\activate for windows

Submitted 3 years, 5 months ago

Thanks @emmanuel4

- p789ahm 3 years, 5 months ago


Latest Blogs