I want to check for
IntegrityError(1048, "Column 'ean' cannot be null").
What is the proper way to do this? I feel like I'm not using the best method.
class Product(models.Model): ean = models.BigIntegerField() name = models.CharField()
Currently I'm doing this crazy trick.
newProduct = Product(ean=None, name='Foo') try: newProduct.save() except IntegrityError, e: error = e code = error.__getslice__(0,1) code = error # handle error 1048
I would love to see a proper example of handling a specific IntegrityError in Python / Django.