
Research
Security News
Malicious npm Packages Target BSC and Ethereum to Drain Crypto Wallets
Socket uncovered four malicious npm packages that exfiltrate up to 85% of a victim’s Ethereum or BSC wallet using obfuscated JavaScript.
django-intl-tel-input
Advanced tools
A Django form widget for international telephone numbers based on the jQuery plugin intl-tel-input.
This package is pre 1.0, so doesn't implement every feature of intl-tel-input. However, it is well tested, and has been stable in production.
Tested on the following versions of Python and Django.
Package | Version support |
---|---|
Python | 2.7, 3.4, 3.5, 3.6, 3.7 |
Django | 1.11, 2.0, 2.1 |
Install from PyPI.
pip install django-intl-tel-input
Add intl-tel-input to your INSTALLED_APPS
, so Django can find the init
script.
...
INSTALLED_APPS += ('intl_tel_input',)
...
Simply add IntlTelInputWidget
to your form field.
from intl_tel_input.widgets import IntlTelInputWidget
class MyForm(forms.ModelForm):
class Meta:
model = MyModel
fields = ['foo', 'bar']
widgets = {
'bar': IntlTelInputWidget()
}
...
With a standard form:
class MyForm(forms.Form):
tel_number = forms.CharField(widget=IntlTelInputWidget())
...
Include {{ form.media.css }}
in the <head>
of your template. This
will ensure all styles are parsed before the widget is displayed.
If you have included jQuery at the end of your document, then don't
forget to update the template where this widget appears with a
{{ form.media.js }}
. Put it in a block that allows it to come after
jQuery.
If you're using
crispy-forms,
the static content will be inserted automatically beside the input. To
prevent this, be sure to set include_media = False
on your form
helper.
class MyForm(forms.Form):
...
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.include_media = False
...
If you need to load all JS in the head, you can make the init.js
script wait for the document to be ready with the following snippet.
jQuery(document).ready(
{{ form.media.js }}
);
All this assumes your form context variable is called form
.
The widget can be invoked with keyword arguments which translate to the options available in intl-tel-input.
Shows the country dropdown.
Default: True
Country code selected by default. Overridden when using auto_geo_ip
.
Default: 'us'
Array of countries that will always appear at the top of the dropdown.
Default: ['us', 'gb']
Use the provided init.js to initialize the plugin. Set this to False
if you want to provide your own initialization for the plugin. This is
useful if, for example, you have your own GeoIP implementation you'd
like to use.
Default: True
FAQs
A Django form widget implementing intl-tel-input.
We found that django-intl-tel-input demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket uncovered four malicious npm packages that exfiltrate up to 85% of a victim’s Ethereum or BSC wallet using obfuscated JavaScript.
Security News
TC39 advances 9 JavaScript proposals, including Array.fromAsync, Error.isError, and Explicit Resource Management, which are now headed into the ECMAScript spec.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.