Django Admin Two-Factor Authentication

Django Admin Two-Factor Authentication, allows you to login django admin with google authenticator.

Why Django Admin Two-Factor Authentication?

  • Using google authenticator to login your Django admin.
  • Used jquery confirm dialog to get code.
  • Simple interface
  • Easy integration

Django Admin Two-Factor Auth

How to use it

  • Download and install last version of Django Admin Two-Factor Authentication:
$ pip install django-admin-two-factor
# or
$ easy_install django-admin-two-factor
  • Add 'admin_two_factor' application to the INSTALLED_APPS setting of your Django project file (note it should be before 'django.contrib.admin'):
# ...
  • Migrate admin_two_factor:
$ python migrate admin_two_factor
$ # or
$ python syncdb
  • Add ‍‍‍‍ADMIN_TWO_FACTOR_NAME in your This value will be displayed in Google Authenticator.
  • Include the Admin Two Factor URL config in PROJECT_CORE/
urlpatterns = [
path('two_factor/', include(('admin_two_factor.urls', 'admin_two_factor'), namespace='two_factor')),
# ...
  • Collect static if you are in production environment:
$ python collectstatic
  • Clear your browser cache

Start the app

$ # Set up the database
$ python makemigrations
$ python migrate
$ # Create the superuser
$ python createsuperuser
$ # Start the application (development mode)
$ python runserver # default port 8000
  • Access the admin section in the browser:


  • User List: the users who have enabled two-factor auth

Django Admin Two-Factor Auth: User List

  • Add New User:

Django Admin Two-Factor Auth: Add New User

  • Scan QRCode and enter the valid code:

Django Admin Two-Factor Auth: Scan QRCode

Django Admin Two-Factor Auth: Login with Code

Download source code from Github

Download ZIP

Submit resources