1๐
I think you can use django-input-mask
package to achieve this. You can install it using pip
.
pip install django-input-mask
You also need to add input_mask
to your INSTALLED_APPS
settings.
To achieve what are you trying to do, you have to create a custom widget.
from input_mask.widgets import InputMask
class SSNInput(InputMask):
mask = {'mask': '999-99-9999'}
class YourForm(forms.ModelForm):
ssn_field = SSNInput()
For more documentation you can see github page
๐คVibhu
Source:stackexchange.com