diff --git a/src/picklefield/fields.py b/src/picklefield/fields.py index 968b66d..d4964ab 100644 --- a/src/picklefield/fields.py +++ b/src/picklefield/fields.py @@ -81,6 +81,7 @@ class PickledObjectField(models.Field): can still do lookups using None). This way, it is still possible to use the ``isnull`` lookup type correctly. """ + empty_strings_allowed = False def __init__(self, *args, **kwargs): self.compress = kwargs.pop('compress', False) diff --git a/src/picklefield/tests.py b/src/picklefield/tests.py index c357569..7098a28 100644 --- a/src/picklefield/tests.py +++ b/src/picklefield/tests.py @@ -64,7 +64,7 @@ def testDataIntegrity(self): # Make sure the default value for default_pickled_field gets stored # correctly and that it isn't converted to a string. - model_test = TestingModel() + model_test = TestingModel(pickle_field=1, compressed_pickle_field=1) model_test.save() model_test = TestingModel.objects.get(id__exact=model_test.id) self.assertEqual((D1, S1, T1, L1), model_test.default_pickle_field) @@ -200,3 +200,7 @@ def testNoCopy(self): compressed_pickle_field='Copy Me', non_copying_field='Dont copy me' ) + + def testAllNonNullFieldsNeedToBeSetForSave(self): + with self.assertRaises(django.db.IntegrityError): + MinimalTestingModel.objects.create()