| 3882 | ## AUPostCodeField ########################################################## |
| 3883 | |
| 3884 | A field that accepts a four digit Australian post code. |
| 3885 | |
| 3886 | >>> from django.contrib.localflavor.au.forms import AUPostCodeField |
| 3887 | >>> f = AUPostCodeField() |
| 3888 | >>> f.clean('1234') |
| 3889 | u'1234' |
| 3890 | >>> f.clean('2000') |
| 3891 | u'2000' |
| 3892 | >>> f.clean('abcd') |
| 3893 | Traceback (most recent call last): |
| 3894 | ... |
| 3895 | django.newforms.util.ValidationError: [u'Enter a post code in the format XXXX.'] |
| 3896 | >>> f.clean('20001') |
| 3897 | Traceback (most recent call last): |
| 3898 | ... |
| 3899 | django.newforms.util.ValidationError: [u'Enter a post code in the format XXXX.'] |
| 3900 | >>> f.clean(None) |
| 3901 | Traceback (most recent call last): |
| 3902 | ... |
| 3903 | django.newforms.util.ValidationError: [u'This field is required.'] |
| 3904 | >>> f.clean('') |
| 3905 | Traceback (most recent call last): |
| 3906 | ... |
| 3907 | django.newforms.util.ValidationError: [u'This field is required.'] |
| 3908 | |
| 3909 | >>> f = AUPostCodeField(required=False) |
| 3910 | >>> f.clean('1234') |
| 3911 | u'1234' |
| 3912 | >>> f.clean('2000') |
| 3913 | u'2000' |
| 3914 | >>> f.clean('abcd') |
| 3915 | Traceback (most recent call last): |
| 3916 | ... |
| 3917 | django.newforms.util.ValidationError: [u'Enter a post code in the format XXXX.'] |
| 3918 | >>> f.clean('20001') |
| 3919 | Traceback (most recent call last): |
| 3920 | ... |
| 3921 | django.newforms.util.ValidationError: [u'Enter a post code in the format XXXX.'] |
| 3922 | >>> f.clean(None) |
| 3923 | u'' |
| 3924 | >>> f.clean('') |
| 3925 | u'' |
| 3926 | |
| 3927 | ## AUPhoneNumberField ######################################################## |
| 3928 | |
| 3929 | A field that accepts a 10 digit Australian phone number. |
| 3930 | llows spaces and parentheses around area code. |
| 3931 | |
| 3932 | >>> from django.contrib.localflavor.au.forms import AUPhoneNumberField |
| 3933 | >>> f = AUPhoneNumberField() |
| 3934 | >>> f.clean('1234567890') |
| 3935 | u'1234567890' |
| 3936 | >>> f.clean('0213456789') |
| 3937 | u'0213456789' |
| 3938 | >>> f.clean('02 13 45 67 89') |
| 3939 | u'0213456789' |
| 3940 | >>> f.clean('(02) 1345 6789') |
| 3941 | u'0213456789' |
| 3942 | >>> f.clean('123') |
| 3943 | Traceback (most recent call last): |
| 3944 | ... |
| 3945 | django.newforms.util.ValidationError: [u'Phone numbers must be in XXXXXXXXXX format.'] |
| 3946 | >>> f.clean('1800DJANGO') |
| 3947 | Traceback (most recent call last): |
| 3948 | ... |
| 3949 | django.newforms.util.ValidationError: [u'Phone numbers must be in XXXXXXXXXX format.'] |
| 3950 | >>> f.clean(None) |
| 3951 | Traceback (most recent call last): |
| 3952 | ... |
| 3953 | django.newforms.util.ValidationError: [u'This field is required.'] |
| 3954 | >>> f.clean('') |
| 3955 | Traceback (most recent call last): |
| 3956 | ... |
| 3957 | django.newforms.util.ValidationError: [u'This field is required.'] |
| 3958 | |
| 3959 | >>> f = AUPhoneNumberField(required=False) |
| 3960 | >>> f.clean('1234567890') |
| 3961 | u'1234567890' |
| 3962 | >>> f.clean('0213456789') |
| 3963 | u'0213456789' |
| 3964 | >>> f.clean('02 13 45 67 89') |
| 3965 | u'0213456789' |
| 3966 | >>> f.clean('(02) 1345 6789') |
| 3967 | u'0213456789' |
| 3968 | >>> f.clean('123') |
| 3969 | Traceback (most recent call last): |
| 3970 | ... |
| 3971 | django.newforms.util.ValidationError: [u'Phone numbers must be in XXXXXXXXXX format.'] |
| 3972 | >>> f.clean('1800DJANGO') |
| 3973 | Traceback (most recent call last): |
| 3974 | ... |
| 3975 | django.newforms.util.ValidationError: [u'Phone numbers must be in XXXXXXXXXX format.'] |
| 3976 | >>> f.clean(None) |
| 3977 | u'' |
| 3978 | >>> f.clean('') |
| 3979 | u'' |
| 3980 | |
| 3981 | ## AUStateSelect ############################################################# |
| 3982 | |
| 3983 | AUStateSelect is a Select widget that uses a list of Australian |
| 3984 | states/territories as its choices. |
| 3985 | |
| 3986 | >>> from django.contrib.localflavor.au.forms import AUStateSelect |
| 3987 | >>> f = AUStateSelect() |
| 3988 | >>> print f.render('state', 'NSW') |
| 3989 | <select name="state"> |
| 3990 | <option value="ACT">Australian Capital Territory</option> |
| 3991 | <option value="NSW" selected="selected">New South Wales</option> |
| 3992 | <option value="NT">Northern Territory</option> |
| 3993 | <option value="QLD">Queensland</option> |
| 3994 | <option value="SA">South Australia</option> |
| 3995 | <option value="TAS">Tasmania</option> |
| 3996 | <option value="VIC">Victoria</option> |
| 3997 | <option value="WA">Western Australia</option> |
| 3998 | </select> |
| 3999 | |