I've a model like this with django 1.1:
class Booking(models.Model):
name = models.CharField(max_length=100)
By default, I'm reading that both 'null' and 'blank' are False.
So with a test like this...
class SimpleTest(TestCase):
def test_booking_save(self):
b = Booking()
b.save()
... I expected the save to throw an exception. But it doesn't. It seems quite happy to create a new record with a blank name (postgres and sqlite3).
I note that via the admin interface a save does indeed fail with a "this field is required".
Questions are:
- Is the 'blank' attribute only applied by forms?
- Is the fix to override the save() method and explicitly check that len(name) != 0?
- Have I misunderstood something which once understood resolves my misunderstanding?