Validated Django model fields for International Bank Account Numbers (IBAN - ISO 13616-1:2007) and SWIFT-BIC (ISO 9362:2009).
Author: Ben Konrath
License: 3-clause BSD
Features:
- Validates IBAN using the official validation algorithm.
- Support for all currently active and planned to be active IBAN countries / numbers.
- Optional validation for IBANs included the Nordea IBAN extensions.
- Optionally limit validation to a list specific of countries.
- Basic validation for SWIFT-BIC.
- Supports Django 1.4, 1.5 and 1.6.
- Python 3.2 and 3.3 support for Django >= 1.5.
Usage:
Use the model fields IBANField and/or SWIFTBICField in your models:
from django.db import models
from django_iban.fields import IBANField, SWIFTBICField
class CustomerModel(models.Model):
iban = IBANField()
swift_bic = SWIFTBICField()
Use the form fields IBANFormField and/or SWIFTBICFormField in your forms:
from django import forms
from django_iban.forms import IBANFormField, SWIFTBICFormField
class CustomerForm(forms.Form):
iban = IBANFormField()
swift_bic = SWIFTBICFormField()
To limit IBAN validation to specific countries, set the 'include_countries' argument with a tuple or list of ISO 3166-1 alpha-2 codes. For example, include_countries=('NL', 'BE, 'LU').
A list of countries that use IBANs as part of SEPA is included for convenience. To use this feature, set include_countries=IBAN_SEPA_COUNTRIES as an argument to the field.
Example:
from django.db import models from django_iban.fields import IBANField, from django_iban.sepa_countries import IBAN_SEPA_COUNTRIES
- class MyModel(models.Model):
- iban = IBANField(include_countries=IBAN_SEPA_COUNTRIES)
In addition to validating official IBANs, this field can optionally validate unofficial IBANs that have been catalogued by Nordea by setting the use_nordea_extensions argument to True.
Development:
Coding style: PEP8 with 120 character lines.
TODO:
- Contribute SWIFT-BIC field to django-localflavor and depreciate this app.
Pull requests happily accepted.