Hello I have simple model:
class Company(models.Model):
name = models.CharField(max_length=150, unique=True, blank=False)
fullname = models.CharField(max_length=250, blank=True, null=True)
description = models.TextField(blank=True, null=False)
...
And I created simple test:
...
def test_create_company_fail_name(self):
""" Why create empty name Models!"""
payload = {
'fullname': 'Test2Django',
'description': 'Simple test',
'country': 'Poland',
'city': 'Gdynia'
}
company = Company.objects.create(**payload)
self.assertEqual(Company.objects.count(), 1)
Why django create model if it didn't get field 'name'? But when I create model in admin section then I get error 'Field is require'.