null attribute specifies that the field can be
null at database level.
This makes the ORM queries and the Python code more complex because the values will sometime be
None and other times, a
Hence, you'd need extra code to check on performing string operations on a
It is recommended to provide a
default='' option to the fields instead.
This way, you wonn't have to worry about null values and the database would also throw an exception if there is an attempt to explicitly save
class Customer(models.Model): remarks = models.CharField(null=True) query = Q(remarks__isnull=True) | Q(remarks='') for customer in Customer.objects.filter(query): ...
class Customer(models.Model): remarks = models.CharField(default='') for customer in Customer.objects.filter(remarks=''): # customer.remarks is always a str ...