| 3559 | # FRZipCodeField ############################################################# |
| 3560 | |
| 3561 | FRZipCodeField validates that the data is a valid FR zipcode. |
| 3562 | >>> from django.contrib.localflavor.fr.forms import FRZipCodeField |
| 3563 | >>> f = FRZipCodeField() |
| 3564 | >>> f.clean('75001') |
| 3565 | u'75001' |
| 3566 | >>> f.clean('93200') |
| 3567 | u'93200' |
| 3568 | >>> f.clean('2A200') |
| 3569 | Traceback (most recent call last): |
| 3570 | ... |
| 3571 | ValidationError: [u'Enter a zip code in the format XXXXX.'] |
| 3572 | >>> f.clean('980001') |
| 3573 | Traceback (most recent call last): |
| 3574 | ... |
| 3575 | ValidationError: [u'Enter a zip code in the format XXXXX.'] |
| 3576 | >>> f.clean(None) |
| 3577 | Traceback (most recent call last): |
| 3578 | ... |
| 3579 | ValidationError: [u'This field is required.'] |
| 3580 | >>> f.clean('') |
| 3581 | Traceback (most recent call last): |
| 3582 | ... |
| 3583 | ValidationError: [u'This field is required.'] |
| 3584 | |
| 3585 | >>> f = FRZipCodeField(required=False) |
| 3586 | >>> f.clean('75001') |
| 3587 | u'75001' |
| 3588 | >>> f.clean('93200') |
| 3589 | u'93200' |
| 3590 | >>> f.clean('2A200') |
| 3591 | Traceback (most recent call last): |
| 3592 | ... |
| 3593 | ValidationError: [u'Enter a zip code in the format XXXXX.'] |
| 3594 | >>> f.clean('980001') |
| 3595 | Traceback (most recent call last): |
| 3596 | ... |
| 3597 | ValidationError: [u'Enter a zip code in the format XXXXX.'] |
| 3598 | >>> f.clean(None) |
| 3599 | u'' |
| 3600 | >>> f.clean('') |
| 3601 | u'' |
| 3602 | |
| 3603 | |
| 3604 | # FRPhoneNumberField ########################################################## |
| 3605 | |
| 3606 | FRPhoneNumberField validates that the data is a valid french phone number. |
| 3607 | It's normalized to 0X XX XX XX XX format. Dots are valid too. |
| 3608 | >>> from django.contrib.localflavor.fr.forms import FRPhoneNumberField |
| 3609 | >>> f = FRPhoneNumberField() |
| 3610 | >>> f.clean('01 55 44 58 64') |
| 3611 | u'01 55 44 58 64' |
| 3612 | >>> f.clean('0155445864') |
| 3613 | u'01 55 44 58 64' |
| 3614 | >>> f.clean('01 5544 5864') |
| 3615 | u'01 55 44 58 64' |
| 3616 | >>> f.clean('01 55.44.58.64') |
| 3617 | u'01 55 44 58 64' |
| 3618 | >>> f.clean('01.55.44.58.64') |
| 3619 | u'01 55 44 58 64' |
| 3620 | >>> f.clean('01,55,44,58,64') |
| 3621 | Traceback (most recent call last): |
| 3622 | ... |
| 3623 | ValidationError: [u'Phone numbers must be in 0X XX XX XX XX format.'] |
| 3624 | >>> f.clean('555 015 544') |
| 3625 | Traceback (most recent call last): |
| 3626 | ... |
| 3627 | ValidationError: [u'Phone numbers must be in 0X XX XX XX XX format.'] |
| 3628 | >>> f.clean(None) |
| 3629 | Traceback (most recent call last): |
| 3630 | ... |
| 3631 | ValidationError: [u'This field is required.'] |
| 3632 | >>> f.clean('') |
| 3633 | Traceback (most recent call last): |
| 3634 | ... |
| 3635 | ValidationError: [u'This field is required.'] |
| 3636 | |
| 3637 | >>> f = FRPhoneNumberField(required=False) |
| 3638 | >>> f.clean('01 55 44 58 64') |
| 3639 | u'01 55 44 58 64' |
| 3640 | >>> f.clean('0155445864') |
| 3641 | u'01 55 44 58 64' |
| 3642 | >>> f.clean('01 5544 5864') |
| 3643 | u'01 55 44 58 64' |
| 3644 | >>> f.clean('01 55.44.58.64') |
| 3645 | u'01 55 44 58 64' |
| 3646 | >>> f.clean('01.55.44.58.64') |
| 3647 | u'01 55 44 58 64' |
| 3648 | >>> f.clean('01,55,44,58,64') |
| 3649 | Traceback (most recent call last): |
| 3650 | ... |
| 3651 | ValidationError: [u'Phone numbers must be in 0X XX XX XX XX format.'] |
| 3652 | >>> f.clean('555 015 544') |
| 3653 | Traceback (most recent call last): |
| 3654 | ... |
| 3655 | ValidationError: [u'Phone numbers must be in 0X XX XX XX XX format.'] |
| 3656 | >>> f.clean(None) |
| 3657 | u'' |
| 3658 | >>> f.clean('') |
| 3659 | u'' |
| 3660 | |
| 3661 | # FRDepartmentSelect ############################################################### |
| 3662 | |
| 3663 | FRDepartmentSelect is a Select widget that uses a list of french departments |
| 3664 | including DOM TOM |
| 3665 | >>> from django.contrib.localflavor.fr.forms import FRDepartmentSelect |
| 3666 | >>> w = FRDepartmentSelect() |
| 3667 | >>> print w.render('dep', 'Paris') |
| 3668 | <select name="dep"> |
| 3669 | <option value="01">01 - Ain</option> |
| 3670 | <option value="02">02 - Aisne</option> |
| 3671 | <option value="03">03 - Allier</option> |
| 3672 | <option value="04">04 - Alpes-de-Haute-Provence</option> |
| 3673 | <option value="05">05 - Hautes-Alpes</option> |
| 3674 | <option value="06">06 - Alpes-Maritimes</option> |
| 3675 | <option value="07">07 - Ardeche</option> |
| 3676 | <option value="08">08 - Ardennes</option> |
| 3677 | <option value="09">09 - Ariege</option> |
| 3678 | <option value="10">10 - Aube</option> |
| 3679 | <option value="11">11 - Aude</option> |
| 3680 | <option value="12">12 - Aveyron</option> |
| 3681 | <option value="13">13 - Bouches-du-Rhone</option> |
| 3682 | <option value="14">14 - Calvados</option> |
| 3683 | <option value="15">15 - Cantal</option> |
| 3684 | <option value="16">16 - Charente</option> |
| 3685 | <option value="17">17 - Charente-Maritime</option> |
| 3686 | <option value="18">18 - Cher</option> |
| 3687 | <option value="19">19 - Correze</option> |
| 3688 | <option value="21">21 - Cote-d'Or</option> |
| 3689 | <option value="22">22 - Cotes-d'Armor</option> |
| 3690 | <option value="23">23 - Creuse</option> |
| 3691 | <option value="24">24 - Dordogne</option> |
| 3692 | <option value="25">25 - Doubs</option> |
| 3693 | <option value="26">26 - Drome</option> |
| 3694 | <option value="27">27 - Eure</option> |
| 3695 | <option value="28">28 - Eure-et-Loire</option> |
| 3696 | <option value="29">29 - Finistere</option> |
| 3697 | <option value="2A">2A - Corse-du-Sud</option> |
| 3698 | <option value="2B">2B - Haute-Corse</option> |
| 3699 | <option value="30">30 - Gard</option> |
| 3700 | <option value="31">31 - Haute-Garonne</option> |
| 3701 | <option value="32">32 - Gers</option> |
| 3702 | <option value="33">33 - Gironde</option> |
| 3703 | <option value="34">34 - Herault</option> |
| 3704 | <option value="35">35 - Ille-et-Vilaine</option> |
| 3705 | <option value="36">36 - Indre</option> |
| 3706 | <option value="37">37 - Indre-et-Loire</option> |
| 3707 | <option value="38">38 - Isere</option> |
| 3708 | <option value="39">39 - Jura</option> |
| 3709 | <option value="40">40 - Landes</option> |
| 3710 | <option value="41">41 - Loir-et-Cher</option> |
| 3711 | <option value="42">42 - Loire</option> |
| 3712 | <option value="43">43 - Haute-Loire</option> |
| 3713 | <option value="44">44 - Loire-Atlantique</option> |
| 3714 | <option value="45">45 - Loiret</option> |
| 3715 | <option value="46">46 - Lot</option> |
| 3716 | <option value="47">47 - Lot-et-Garonne</option> |
| 3717 | <option value="48">48 - Lozere</option> |
| 3718 | <option value="49">49 - Maine-et-Loire</option> |
| 3719 | <option value="50">50 - Manche</option> |
| 3720 | <option value="51">51 - Marne</option> |
| 3721 | <option value="52">52 - Haute-Marne</option> |
| 3722 | <option value="53">53 - Mayenne</option> |
| 3723 | <option value="54">54 - Meurthe-et-Moselle</option> |
| 3724 | <option value="55">55 - Meuse</option> |
| 3725 | <option value="56">56 - Morbihan</option> |
| 3726 | <option value="57">57 - Moselle</option> |
| 3727 | <option value="58">58 - Nievre</option> |
| 3728 | <option value="59">59 - Nord</option> |
| 3729 | <option value="60">60 - Oise</option> |
| 3730 | <option value="61">61 - Orne</option> |
| 3731 | <option value="62">62 - Pas-de-Calais</option> |
| 3732 | <option value="63">63 - Puy-de-Dome</option> |
| 3733 | <option value="64">64 - Pyrenees-Atlantiques</option> |
| 3734 | <option value="65">65 - Hautes-Pyrenees</option> |
| 3735 | <option value="66">66 - Pyrenees-Orientales</option> |
| 3736 | <option value="67">67 - Bas-Rhin</option> |
| 3737 | <option value="68">68 - Haut-Rhin</option> |
| 3738 | <option value="69">69 - Rhone</option> |
| 3739 | <option value="70">70 - Haute-Saone</option> |
| 3740 | <option value="71">71 - Saone-et-Loire</option> |
| 3741 | <option value="72">72 - Sarthe</option> |
| 3742 | <option value="73">73 - Savoie</option> |
| 3743 | <option value="74">74 - Haute-Savoie</option> |
| 3744 | <option value="75">75 - Paris</option> |
| 3745 | <option value="76">76 - Seine-Maritime</option> |
| 3746 | <option value="77">77 - Seine-et-Marne</option> |
| 3747 | <option value="78">78 - Yvelines</option> |
| 3748 | <option value="79">79 - Deux-Sevres</option> |
| 3749 | <option value="80">80 - Somme</option> |
| 3750 | <option value="81">81 - Tarn</option> |
| 3751 | <option value="82">82 - Tarn-et-Garonne</option> |
| 3752 | <option value="83">83 - Var</option> |
| 3753 | <option value="84">84 - Vaucluse</option> |
| 3754 | <option value="85">85 - Vendee</option> |
| 3755 | <option value="86">86 - Vienne</option> |
| 3756 | <option value="87">87 - Haute-Vienne</option> |
| 3757 | <option value="88">88 - Vosges</option> |
| 3758 | <option value="89">89 - Yonne</option> |
| 3759 | <option value="90">90 - Territoire de Belfort</option> |
| 3760 | <option value="91">91 - Essonne</option> |
| 3761 | <option value="92">92 - Hauts-de-Seine</option> |
| 3762 | <option value="93">93 - Seine-Saint-Denis</option> |
| 3763 | <option value="94">94 - Val-de-Marne</option> |
| 3764 | <option value="95">95 - Val-d'Oise</option> |
| 3765 | <option value="2A">2A - Corse du sud</option> |
| 3766 | <option value="2B">2B - Haute Corse</option> |
| 3767 | <option value="971">971 - Guadeloupe</option> |
| 3768 | <option value="972">972 - Martinique</option> |
| 3769 | <option value="973">973 - Guyane</option> |
| 3770 | <option value="974">974 - La Reunion</option> |
| 3771 | <option value="975">975 - Saint-Pierre-et-Miquelon</option> |
| 3772 | <option value="976">976 - Mayotte</option> |
| 3773 | <option value="984">984 - Terres Australes et Antarctiques</option> |
| 3774 | <option value="986">986 - Wallis et Futuna</option> |
| 3775 | <option value="987">987 - Polynesie Francaise</option> |
| 3776 | <option value="988">988 - Nouvelle-Caledonie</option> |
| 3777 | </select> |
| 3778 | |