from django.db import IntegrityError except IntegrityError as e: if 'unique constraint' in e.message: # or e.args[0] from Django 1.10 #do something
from django.db import IntegrityError except IntegrityError as e: if 'unique constraint' in e.message: # or e.args[0] from Django 1.10 #do something