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
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter