jazzband / django-two-factor-auth

Complete Two-Factor Authentication for Django providing the easiest integration into most Django projects.
MIT License
1.71k stars 448 forks source link

Not compatible with Django 4.0.3 ? 'two_factor_tags' is not a registered tag library #532

Closed polow closed 2 years ago

polow commented 2 years ago

Getting this error using latest Django 4.0.3

TemplateSyntaxError at /account/login/

Expected Behavior

Load the login page

Current Behavior

Getting this Error : TemplateSyntaxError at /account/login/ 'two_factor_tags' is not a registered tag library. Must be one of: admin_list admin_modify admin_urls cache crispy_forms_field crispy_forms_filters crispy_forms_tags crispy_forms_utils i18n l10n log static tz

Possible Solution

Tried adding templatetags folder in the root directory but same error

Steps to Reproduce (for bugs)

  1. Install package with pip install django-two-factor-auth
  2. add required parameters in settings
  3. restart server and start again

Context

Your Environment

claudep commented 2 years ago

Are you sure that 'two_factor' is in your INSTALLED_APPS setting?

polow commented 2 years ago

Are you sure that 'two_factor' is in your INSTALLED_APPS setting?

Yep INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles',

2fa

'django_otp',
'django_otp.plugins.otp_static',
'django_otp.plugins.otp_totp',
# 'django_otp.plugins.otp_email',  # <- if you want email capability.
'two_factor',
# 'two_factor.plugins.phonenumber',  # <- if you want phone number capability.
# 'two_factor.plugins.email',  # <- if you want email capability.
# 'two_factor.plugins.yubikey',  # <- for yubikey capability.

# 3rd Party [Bootstrap]
"crispy_forms",
"crispy_bootstrap5",

# My Private Apps
'accounts.apps.AccountsConfig',
'employee.apps.EmployeeConfig',

]

claudep commented 2 years ago

Ah, I see. In the next release, this will work, but in 1.14.0, the two_factor_tags template library is still inside the phonenumber plugin. So you have to uncomment 'two_factor.plugins.phonenumber' in INSTALLED_APPS to make it work (until the next release).

polow commented 2 years ago

Well uncommenting that line didn't help, will wait for the next update. Thank you.

mksaf commented 2 years ago

I've just spent way too much time googling this error.

TLDR : When you download this project, you will get the "master" version, which is NOT the 1.14.0 version. After downloading that one manually, everything works like a charm. :)

claudep commented 2 years ago

When you download this project, you will get the "master" version

Which way did you download?

polow commented 2 years ago

I've just spent way too much time googling this error.

TLDR : When you download this project, you will get the "master" version, which is NOT the 1.14.0 version. After downloading that one manually, everything works like a charm. :)

In my case The structurer of my project template is a bit different , I keep template files in each app's directory and since I have a separate app for my project auths and users named 'accounts' I fixed the error by including 'templatetags' folder in the root directory of my 'accounts' app folder and kept 'two_factor' folder in my 'templates' folder in the root directory of my project.

This fixed most of the errors but still there are others I am trying to figure them out.