United Arab Emirates (ae)¶
The UAE localflavor provides helpers for the most common address and registration values used in local applications.
Highlights:
UAEEmiratesIDFieldaccepts Emirates ID numbers in either compact784YYYYNNNNNNNNform or formatted784-YYYY-NNNNNNN-Nform and stores them in normalized dashed form.UAEPostalCodeFieldreflects local practice by allowing only00000or an empty value.UAEPOBoxFieldaccepts plain numeric values as well asP.O. Box,PO Box, andPOBprefixes.UAETaxRegistrationNumberFieldvalidates 15-digit VAT/TRN identifiers and strips embedded whitespace during cleaning.
Forms¶
UAE-specific Form helpers.
- class localflavor.ae.forms.UAEEmirateField(**kwargs)[source]¶
A choice field that uses a list of UAE Emirates as its choices.
Added in version 5.1.
- class localflavor.ae.forms.UAEEmirateSelect(attrs=None)[source]¶
A Select widget that uses a list of UAE Emirates as its choices.
Added in version 5.1.
- class localflavor.ae.forms.UAEEmiratesIDField(**kwargs)[source]¶
A field for validating UAE Emirates ID numbers.
UAE Emirates ID format: 784-YYYY-NNNNNNN-N Where: - 784 is the UAE country code - YYYY is an identification block assigned by ICP - NNNNNNN is a 7-digit sequence number - N is a single check digit
Added in version 5.1.
- class localflavor.ae.forms.UAEPOBoxField(**kwargs)[source]¶
A field for validating UAE P.O. Box numbers.
Accepts formats: “P.O. Box XXXXX”, “PO Box XXXXX”, “POB XXXXX”, or just “XXXXX”
Added in version 5.1.
- class localflavor.ae.forms.UAEPostalCodeField(**kwargs)[source]¶
A field for validating UAE postal codes.
UAE doesn’t use postal codes, but some systems require “00000”. This field accepts “00000” or empty values.
Added in version 5.1.
Models¶
UAE-specific Model helpers.
- class localflavor.ae.models.UAEEmirateField(*args, **kwargs)[source]¶
A model field for UAE Emirates.
Stores emirate as a 2-character abbreviation (e.g., ‘DU’ for Dubai).
Added in version 5.1.
- deconstruct()[source]¶
Return enough information to recreate the field as a 4-tuple:
The name of the field on the model, if contribute_to_class() has been run.
The import path of the field, including the class, e.g. django.db.models.IntegerField. This should be the most portable version, so less specific may be better.
A list of positional arguments.
A dict of keyword arguments.
Note that the positional or keyword arguments must contain values of the following types (including inner values of collection types):
None, bool, str, int, float, complex, set, frozenset, list, tuple, dict
UUID
datetime.datetime (naive), datetime.date
top-level classes, top-level functions - will be referenced by their full import path
Storage instances - these have their own deconstruct() method
This is because the values here must be serialized into a text format (possibly new Python code, possibly JSON) and these are the only types with encoding handlers defined.
There’s no need to return the exact way the field was instantiated this time, just ensure that the resulting field is the same - prefer keyword arguments over positional ones, and omit parameters with their default values.
- class localflavor.ae.models.UAEEmiratesIDField(*args, **kwargs)[source]¶
A model field for UAE Emirates ID numbers.
Stores Emirates ID as a 15-digit string with format: 784-YYYY-NNNNNNN-N
Added in version 5.1.
- class localflavor.ae.models.UAEPOBoxField(*args, **kwargs)[source]¶
A model field for UAE P.O. Box numbers.
Stores P.O. Box numbers as strings (numeric only).
Added in version 5.1.
Data¶
- localflavor.ae.ae_emirates.EMIRATE_CHOICES = (('AZ', 'Abu Dhabi'), ('AJ', 'Ajman'), ('DU', 'Dubai'), ('FU', 'Fujairah'), ('RA', 'Ras Al Khaimah'), ('SH', 'Sharjah'), ('UQ', 'Umm Al Quwain'))¶
A list of UAE emirates as (abbreviation, name) tuples.
- localflavor.ae.ae_emirates.EMIRATES_NORMALIZED = {'AJ': 'AJ', 'AZ': 'AZ', 'DU': 'DU', 'FU': 'FU', 'RA': 'RA', 'SH': 'SH', 'UQ': 'UQ', 'abu dhabi': 'AZ', 'aj': 'AJ', 'ajman': 'AJ', 'az': 'AZ', 'du': 'DU', 'dubai': 'DU', 'fu': 'FU', 'fujairah': 'FU', 'ra': 'RA', 'ras al khaimah': 'RA', 'ras al-khaimah': 'RA', 'sh': 'SH', 'sharjah': 'SH', 'umm al quwain': 'UQ', 'umm al-quwain': 'UQ', 'uq': 'UQ', 'أبو ظبي': 'AZ', 'أم القيوين': 'UQ', 'الشارقة': 'SH', 'الفجيرة': 'FU', 'دبي': 'DU', 'رأس الخيمة': 'RA', 'عجمان': 'AJ'}¶
Dictionary that maps emirate names and abbreviations to the canonical abbreviation.