Changes between Initial Version and Version 1 of Ticket #4136, comment 24

07/19/12 00:30:56 (11 years ago)
Melvyn Sopacua


  • Ticket #4136, comment 24

    initial v1  
    33Also the simplest option is to always insert as NULL if null and unique are True as there are very few real world cases where an empty value is an actual valid option. One could also make this case for non-unique but null fields, however there's no actual distinction between a NULL value and an empty string in this case.
     5And there may be another solution. Backwards compatibility may be an issue but I think solvable. Instead of the blank field being a boolean, make it an integer flag:
     6- blank = models.RESTRICT acts as blank=False now
     7- blank = models.SET_EMPTY acts as blank=True now and sets field to the 'empty' value
     8- blank = models.SET_DEFAULT sets a blank value to the field's default value
     9- blank = models.SET_NULL sets a blank value to the NULL if null=True or raises ValueError if null=False
     11If RESTRICT and SET_EMPTY are 0 and 1 respectively the setting can be set coerced to int and be backwards compatible. All in all I think the cleanest solution in the long run.
Back to Top