IBAN / BIC

Most countries over the world use IBAN for international payments. Starting at August 1, 2014, the European Union has mandated that all its member countries must use IBAN for domestic and international transactions. Even if your country does not require IBAN for domestic transactions, it may be a good idea to use and store IBANs anyway. This allows you to handle bank account numbers from different countries.

IBAN

class internationalflavor.iban.validators.IBANValidator(countries=None, exclude=None, sepa_only=False, accept_experimental=False)

Validator for checking whether a given IBAN is valid. An IBAN consists of up to 34 alphanumeric characters, where the first two characters indicate a country code, the third and fourth indicate a checksum and the rest of the IBAN are localized characters (the so-called BBAN).

Parameters:
  • countries – If set, the list of source countries will be limited to the provided list. Otherwise, all available IBANs are included (with the exception of experimental IBANs if accept_experimental is not set).
  • exclude – You can use this parameter to exclude items from the list of countries.
  • sepa_only (bool) – By default, all countries are allowed. If you want to reduce the list of countries to the list of SEPA countries (i.e. Single European Payments Area), for instance if you are an European company wanting to perform direct debits, you can set this to True. This is equivalent to setting the exclude list to all countries without SEPA.
  • accept_experimental (bool) – By default, this validator will validate any IBAN that is recognized by the SWIFT organization, but SWIFT has specified a few additional IBAN formats and defined them as ‘experimental’. By setting this parameter to True, these extensions are also allowed.

Warning

The validation of the experimental numbers may be wrong for some countries, as only their length is published by the SWIFT organization

class internationalflavor.iban.models.IBANField(countries=None, exclude=None, sepa_only=False, accept_experimental=False, *args, **kwargs)

A model field that applies the validators.IBANValidator and is represented by a forms.IBANFormField. The arguments are equal to those of the validator.

Example:

from django.db import models
from internationalflavor.iban import IBANField

class MyModel(models.Model):
    iban = IBANField(countries=['NL', 'BE'])

This field is an extension of a CharField.

class internationalflavor.iban.forms.IBANFormField(countries=None, exclude=None, sepa_only=False, accept_experimental=False, *args, **kwargs)

A form field that applies the validators.IBANValidator. The arguments are equal to those of the validator.

This field represents the data in 4-character blocks, but stores it internally without any formatting.

BIC

class internationalflavor.iban.validators.BICValidator
class internationalflavor.iban.models.BICField(*args, **kwargs)

A model field that applies the validators.BICValidator and is represented by a forms.BICFormField.

This field is an extension of a CharField.

class internationalflavor.iban.forms.BICFormField(*args, **kwargs)

A form field that applies the validators.BICValidator.

Comparison with other packages

localflavor
Both an IBANField and a BICField are provided by this module. Although internationalflavor and localflavor have different approaches to validation, if you are already using localflavor and do not need any of the other fields provided by internationalflavor, you may be better off choosing localflavor (and vice versa).
django-iban
The validation in this module is equal to the localflavor validation. The author of this package is seeking to retire his package, so it may be best to not use this package in new projects.

See also

IBAN Registry
The official IBAN format registry of SWIFT.
IBAN Structure
Additional IBAN formats listed as experimental
Wikipedia: International Bank Account Number
More information on IBAN