Django VIES

raw JSON →
6.3.0 verified Fri May 01 auth: no python

Validate and store VAT Information Exchange System (VIES) data in Django. Current version 6.3.0, requires Python >=3.10 and Django >=4.2. Active maintenance.

pip install django-vies
error ModuleNotFoundError: No module named 'django_vies'
cause Package not installed or installed in wrong environment.
fix
pip install django-vies
error ImportError: cannot import name 'VATINModelField' from 'django_vies.models'
cause Since v6, the model field is renamed to VATINField (no 'ModelField' suffix).
fix
from django_vies.models import VATINField
error django.core.exceptions.ImproperlyConfigured: VATINField requires 'requests' library
cause Missing requests (or suds-py3) for VIES SOAP requests.
fix
pip install requests
breaking In v6, the model field no longer has a separate VATINModelField; use VATINField from models module.
fix Change imports: from django_vies.models import VATINField (not VATINModelField)
gotcha VIES SOAP service may be slow or unreliable; fields accept 'None' for offline fallback.
fix Set blank=True, null=True to allow empty VAT numbers; handle validation asynchronously if needed.
deprecated The suds-py3 dependency is deprecated; use requests-based backend (default since v5).
fix Upgrade to v6 and ensure no custom SOAP backend configuration.

Add a VIES-validated VAT field to a Django model.

from django_vies.fields import VATINField
from django.db import models

class Company(models.Model):
    name = models.CharField(max_length=100)
    vat = VATINField(blank=True, null=True)

# Usage:
from django_vies.validators import VATINValidator
validator = VATINValidator()
try:
    validator('DE123456789')
    print('Valid VAT')
except Exception as e:
    print('Invalid:', e)