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?
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.