How do I create a Real Time Password Strength Checker for my forms which have PasswordField in Django?

Hi there,

I want to create a real time (live) Password Strength Checker which shows Weak, Normal and Strong etc or any kind of live strength-bar under the password fields on front-end while I type the password.

I tried this plugin here, but it does not seem to work as it has not been updated.

Can anyone tell me how do I accomplish it?

Hey there!
If you take a closer look into the code from the plugin, you will notice that they used Js to do the Job.

I am not good at js, can you tell me how do I implement the plugin? I was earlier getting some errors related to ugettext() method as it’s been depreciated. So what I did is to manually enter the code of widgets.py from plugin to my own forms.py, and implemented PasswordStrengthField as told in the plugin instructions. It’s working but it;s just showing a static and same message that is This password can be cracked, the message does not update as I start to type password, it just never changes.

So I guess it has to do with the JS. Can you help me in implementing the JS. I have put all the JS files provided in the plugin package into my project-folder/static/django_password_strength/js and my settings.py has following code:

STATIC_URL = "/static/"

STATICFILES_DIRS = [BASE_DIR / "static"]

Will this work?

I just checked the app and it did not work.

I’m not really good at Js as well. The package is failing cause it’s not compatible with your version of django.
But one thing that can work it’s to fork the repository and make it compatible with the django version, and install from your github.

About the error you’re facing is because:
The ugettext_lazy / ugettext was replaced by gettext_lazy / gettext.
Maybe there will be more errors.

1 Like