django-two-facto-auth package


I have a Django project that I am trying to incorporate the django-two-factor-auth package into, essentially replacing my existing login process with the django-two-factor-auth flow.

I have the package and the phonenumbers package installed. I added everything from the install guide into the file (Installation — Django Two-Factor Authentication 1.13.1 documentation). I then added the url pattern to my root file.

I think the issue is that the path from the 2fa guide might be conflicting with the path I had to my login page. My login page is the root of my project and is the first page presented when one go to

Django-two-factor-auth url pattern = path(’’, include(tf_urls)),
Existing url pattern for login = path(’’, include(‘account.urls’)),

Commenting out the existing path results in Page Not Found error, and shows all of the two_factor urls.

I have tried placing the 2fa url into the account.urls file and get the same error(s).
I have also tried keeping my existing login page and redirecting to 2fa after successful login, this results in a “two_factor is not a registered namespace” error.

How can to implement 2fa on top of my existing login flow?

I am still interested if anyone can provide another answer to my question but I have a solution that I am working with now.

I just imported the two_factor package views into my root file and specified the login view class. This gets me the two factor login page when browsing to the root of my project

import two_factor.views.core  as tf_views
urlpatterns = [
    path('', tf_views.LoginView.as_view(), name='Login'),