Qatar (qa)¶
The Qatar localflavor provides helpers for validating Qatari National ID numbers used in forms and model fields, plus a municipality choice field.
Data¶
Forms¶
Models¶
- class localflavor.qa.models.QAMunicipalityField(*args, **kwargs)[source]¶
A model field for Qatar municipalities.
Stores the municipality as a 2-character ISO 3166-2:QA code (e.g.
'DA'for Ad Dawhah / Doha).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.
Validators¶
- class localflavor.qa.validators.QANationalIDValidator(*args, **kwargs)[source]¶
Validate Qatari National ID numbers.
Format:
CYYNNNSSSSSWhere: -
Cis the century digit (2 or 3) -YYis the last two digits of the year of birth -NNNis an ISO 3166-1 numeric nationality code -SSSSSis a unique serial number- Checks the following rules to determine the validity of the number:
The number consists of 11 digits.
The century digit is valid (2 or 3).
The year of birth is not in the future.
The nationality code is a valid ISO 3166-1 numeric country code.
Added in version 5.1.
- deconstruct()¶
Return a 3-tuple of class import path, positional arguments, and keyword arguments.