Skip to content

aj-may/django-password-strength

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django Password Strength

An extension of the Django password widget including a password strength meter and crack time powered by zxcvbn.

Empty Password

Weak Password

Strong Password

Install:

> pip install django-password-strength

Usage:

  • Add django_password_strength to the installed apps of your Django Project
  • Instead of using the django PasswordInput widget use the PasswordStrengthInput
  • Be sure to include the form's required media in the template. ie. {{ form.media }}
  • If you bundle your js you can use django_password_strength/js/zxcvbn.js or django_password_strength/js/zxcvbn-async.js and django_password_strength/js/password_strength.js instead
  • For easiest integration also include Twitter Bootstrap

Translations:

There are currently no translations already available, but all the text is translatable, you just have to translate it yourself.

For the javascript translations be sure to add the javascript translation catalog provided by django or use something like django-statici18n for a static version of the catalog. If you don't want translations you don't have to add the catalog to your page.

Example:

forms.py

from django import forms
from django_password_strength.widgets import PasswordStrengthInput, PasswordConfirmationInput

class SignupForm(forms.Form):
    username = forms.CharField()
    passphrase = forms.CharField(
        widget=PasswordStrengthInput()
    )
    confirm_passphrase = forms.CharField(
        widget=PasswordConfirmationInput()
    )

Example using multiple password fields:

forms.py

from django import forms
from django_password_strength.widgets import PasswordStrengthInput, PasswordConfirmationInput

class SignupForm(forms.Form):
    username = forms.CharField()
    passphrase = forms.CharField(
        widget=PasswordStrengthInput()
    )
    confirm_passphrase = forms.CharField(
        widget=PasswordConfirmationInput(confirm_with='passphrase')
    )

    passphrase2 = forms.CharField(
        widget=PasswordStrengthInput()
    )
    confirm_passphrase2 = forms.CharField(
        widget=PasswordConfirmationInput(confirm_with='passphrase2')
    )

About

A Smarter Password Strength Meter

Resources

License

Stars

Watchers

Forks

Packages

No packages published