Django ArrayField null = True Migration with Postgresql

So, in the Django docs for creating new fields in Postgresql says ( Full description ):

... it is recommended that you always create new columns with null=True , as they will be added immediately.

What if I want to create an ArrayField, something like this:

 tags = ArrayField(models.CharField(max_length=255, blank=True, default=''), default=list, null=True) 

Should I pass null=True to the CharField that is inside this ArrayField ?

+6
source share
1 answer

I don't think setting null=True for an internal type gives you any benefit. The note in the documents you are referring to applies only to the column itself, so as long as ArrayField can ArrayField , the database does not have to completely rewrite the table.

If you let the inner type be null, you have to deal with this in your code, which may not be exactly what you want.

+6
source

Source: https://habr.com/ru/post/1247106/


All Articles