Hi Karen, Many thanks for your reply. Now our business requirements do not allow either empty string or null value for this particular charField column (name = models.CharField(max_length=512, null=False, blank=False)). How do you suggest we should configure this field so that we can enforce not null condition in the oracle database by using syncdb? Currently, after creating those tables we need to manually modify the column properties in Oracle to make them not null. Or Django Oracle backend deliberately ignores null=false for charField creation?
Wayne On Feb 26, 8:47 pm, Karen Tracey <kmtra...@gmail.com> wrote: > On Fri, Feb 26, 2010 at 5:35 PM, Wayne <wayneshen...@gmail.com> wrote: > > Hi, > > I try to create tables using Django models in our test oracle > > database. I define a model with one column like this: name = > > models.CharField(max_length=512, null=False, blank=False). After > > running python manage.py syncdb, I found that column 'name' in the > > generated table still allows null value in the column definition. I > > understand that null = false is the default option. And I verified > > that for other types of Django fields, null = false or no such option > > at all would generate columns that do not allow null values in the > > database. Is there particular reason why null = false is not enforced > > for charField? > > Yes. Oracle does not distinguish between null and an empty string. So > null=False applied at the database level would mean that you also could not > store the empty string in that field, which would be quite different from > what you would see running the same code on most other databases, where the > empty string is a valid value for a NOT NULL character field. > > The behavior is documented, see the note > here:http://docs.djangoproject.com/en/dev/ref/models/fields/#null. The note is > perhaps not as clear as it could be about when the empty string is allowed > for a field. That's a property of the field type (for example, empty strings > are allowed for CharField but not a DateField), and is not in any way tied > to the value of the field's blank option. The blank option, as noted in its > description, is used for validation and is not applied at the database > level. > > Karen -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.