How to fix 'qr_code' is not a registered tag library. in Django and HTML
How to fix 'qr_code' is not a registered tag library. I use Django version 4.1.4.
setting.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'myapp',
'qrcode',
]
In setting.py, if I use qr_code instead of qrcode, this error will occur ModuleNotFoundError: No module named 'qr_code'.
It will display the error 'qr_code' is not a registered tag library.
{% load qr_code %}
{% qr_from_text request.build_absolute_uri size="T" image_format="png" error_correction="T" %}
In HTML, how should I edit?
Command I used to install
django-qr-code 3.1.1
pip install django-qr-code
And I tried installing it with conda after trying it in pip and it didn't work.
conda install -c auto django-qrcode
Update and reinstall the module/library again.I got the similar error for other installation of libraries. Maybe uninstalling the module or installing it in new environment in conda might help.
You installed a different library. Indeed, you installed django-qrcode
[pypi], not django-qr-code
[pypi].
The two are however very similar, you only need to work with:
{% load qr_tags %} {% qr_from_text request.build_absolute_uri size="T" image_format="png" error_correction="T" %}