I have a model like this with Django 1.1:
class Booking(models.Model): name = models.CharField(max_length=100)
By default, I read 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 to keep throwing an exception. But this is not so. It seems quite happy to create a new entry with an empty name (Postgres and SQLite3).
I note that through the admin interface, the failure does indeed occur with a "required field".
Questions:
- Is the 'blank' attribute applicable only to forms?
- Is there a fix for overriding the save () method and explicitly checks that len ββ(name)! = 0?
- Did I misunderstand what I once understood resolves my misunderstanding?
django django-models
John mee
source share