Utils¶
Widgets¶
django-intranet
provides you with extra widgets for your form fields:
- The PhoneField, extended from Django’s CharField, enforces the entered data of the field to be in the form of a valid telephone number, and then django-intranet will refuse to save a wrong phone number in your database. The telephone number can have a prefix code, for example “+81.0123456789”. If it doesn’t have one, django-intranet will consider we are in France by default. It will then remove separating characters like ‘ ‘ or ‘.’, check the number of digits, and then save the number with the telephone code “+33.”.
- The SiretField, extended from Django’s CharField, enforces the entered data of the field to be in the form of a valid SIRET number. So django-intranet will check the number of digits and then use a simple algorithm to check if the entered number is a valid SIRET number.
Filters¶
You can also use the associated filters in your html templates:
- The filter “phone” transforms a number in the form “+81.0123456789” into “+810123456789” and a number in the form “+33.384289468” into “03 84 28 94 68” for better readablility.
- The filter “siret” transforms a number in the form “01234567890128” into “012 345 678 90128” for better readablility.