United Arab Emirates (ae)

The UAE localflavor provides helpers for the most common address and registration values used in local applications.

Highlights:

  • UAEEmiratesIDField accepts Emirates ID numbers in either compact 784YYYYNNNNNNNN form or formatted 784-YYYY-NNNNNNN-N form and stores them in normalized dashed form.

  • UAEPostalCodeField reflects local practice by allowing only 00000 or an empty value.

  • UAEPOBoxField accepts plain numeric values as well as P.O. Box, PO Box, and POB prefixes.

  • UAETaxRegistrationNumberField validates 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.

clean(value)[source]

Validate the given value and return its “cleaned” value as an appropriate Python object. Raise ValidationError for any errors.

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.

clean(value)[source]

Validate the given value and return its “cleaned” value as an appropriate Python object. Raise ValidationError for any errors.

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.

clean(value)[source]

Validate the given value and return its “cleaned” value as an appropriate Python object. Raise ValidationError for any errors.

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.

clean(value)[source]

Validate the given value and return its “cleaned” value as an appropriate Python object. Raise ValidationError for any errors.

class localflavor.ae.forms.UAETaxRegistrationNumberField(**kwargs)[source]

A field for validating UAE Tax Registration Numbers (TRN).

UAE TRN is a 15-digit number used for VAT registration.

Added in version 5.1.

clean(value)[source]

Validate the given value and return its “cleaned” value as an appropriate Python object. Raise ValidationError for any errors.

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.

formfield(**kwargs)[source]

Return a django.forms.Field instance for this field.

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.

formfield(**kwargs)[source]

Return a django.forms.Field instance for this field.

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.

formfield(**kwargs)[source]

Return a django.forms.Field instance for this field.

class localflavor.ae.models.UAEPostalCodeField(*args, **kwargs)[source]

A model field for UAE postal codes.

UAE doesn’t use postal codes, but stores “00000” if required.

Added in version 5.1.

formfield(**kwargs)[source]

Return a django.forms.Field instance for this field.

class localflavor.ae.models.UAETaxRegistrationNumberField(*args, **kwargs)[source]

A model field for UAE Tax Registration Numbers (TRN).

Stores TRN as a 15-digit string for VAT purposes.

Added in version 5.1.

formfield(**kwargs)[source]

Return a django.forms.Field instance for this field.

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.