Skip to main content

Password field for Django with the eye icon to show/hide password text

Project description

https://img.shields.io/pypi/v/django_password_eye.svg

A Django field and widget to show the ‘eye’ icon that shows and hides password.

https://raw.githubusercontent.com/hmeza/django_password_eye/master/misc/readme-image.png

Requirements

Font Awesome. It is included in the widget by default.

Install

` pip install django-password-eye `

In settings, add django_password_eye to INSTALLED_APPS:

INSTALLED_APPS = [
‘django.contrib.admin’,
‘django.contrib.auth’,
‘django_password_eye’,
]

By default, it includes the Font Awesome css library

If you do not want to include it because you already include it from another template, just set this in your settings file:

` DJANGO_PASSWORD_EYE_INCLUDE_FONT_AWESOME = False `

Usage

Import PasswordEye and use it instead of the traditional Password field.

from django_password_eye.fields import PasswordEye

class LoginForm(forms.Form):
    username = forms.CharField(max_length=150,
                           widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': _('Login')}),
                           label='')
    password = PasswordEye(label='')

Independent behavior for inputs

In case you need to trigger the show/hide password for any PasswordEye field, specify the PasswordEyeWidget for the PasswordEye and add the parameter independent=True, which defaults to false:

from django_password_eye.fields import PasswordEye
from django_password_eye.widgets import PasswordEyeWidget

input = PasswordEye(widget=PasswordEyeWidget(independent=True))
code

CSS classes

By using the css class django_password_eye as selector, you can customize the entire widget. Check template input.html.

I suggest to modify link class to add cursor: hand/pointer, but it is up to you.

Source code

The code was taken from this link

https://codepen.io/Qanser/pen/dVRGJv

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_password_eye-1.1.4.tar.gz (43.1 kB view details)

Uploaded Source

Built Distribution

django_password_eye-1.1.4-py3-none-any.whl (31.0 kB view details)

Uploaded Python 3

File details

Details for the file django_password_eye-1.1.4.tar.gz.

File metadata

  • Download URL: django_password_eye-1.1.4.tar.gz
  • Upload date:
  • Size: 43.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.10

File hashes

Hashes for django_password_eye-1.1.4.tar.gz
Algorithm Hash digest
SHA256 96fd7221aa379471d8fbe9850ba86eebb9dcb5f89908e51e05713f2beec148b6
MD5 6126fde8fbf6ad11731c4df2c7ab8dca
BLAKE2b-256 573d16a61eceb4c7f3fdb1cb04bfddbcf5deeee79bcf74965ca0372eab3bfe22

See more details on using hashes here.

File details

Details for the file django_password_eye-1.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for django_password_eye-1.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6c5e008e096c4c63860b60f36b6c072c370392508a68f315b9e3a988af510cf5
MD5 65757050810e605f5e7a4b353574d6a9
BLAKE2b-256 dcc00b8503cb9ff12d465c19412eed0a1949be5c51d5010fbf4314d219d93cd7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page