Achimnol
Achimnol

Reputation: 1599

How to distinguish field that requires null=True when blank=True is set in Django models?

Some model fields such as DateTimeField require null=True option when blank=True option is set.

I'd like to know which fields require that (maybe dependent on backend DBMS), and there is any way to do this automatically.

Upvotes: 2

Views: 441

Answers (2)

hannson
hannson

Reputation: 4515

This post should help to understand the difference on blank and null in Django

Upvotes: 2

Anurag Uniyal
Anurag Uniyal

Reputation: 88757

null=True is used to tell that in DB value can be NULL blank=True is only for django , so django doesn't raise error if field is blank e.g. in admin interface so blank=True has nothing to do with DB NULL requirement will vary from DB to DB, and it is upto you to decide if you want some column NULL or not

Upvotes: 2

Related Questions