Some odd behavior with Oracle involving blank and null.blank is True on this field:my_auto = models.AutoField(blank=False, null=False, primary_key=True)null is True on this field:uncles = models.ManyToManyField(Uncle, blank=False, null=False)
These two have nothing to do with Oracle specifically. AutoFields are coerced to blank=True regardless of backend. You can see that here:
https://github.com/django/django/blob/master/django/db/models/fields/__init__.py#L534
I don't know exactly why this is done, but I would guess it is because the point of the AutoField is that it can be left blank and automatically be filled in. If you don't want that, then you probably want an IntegerField instead.
I'm not sure where null=True is getting set on the ManyToManyField, but I guess that the reason for this is that null=False represents a database constraint, and there is no way to actually set that constraint because the field does not map to an actual column in the model table; it maps to an intermediate relational table instead.
null is True on this field:photo = models.ImageField(upload_to="uploads/")
This one is due to Oracle, because ImageField is a string-based field (it stores the filename where the image is stored). A null value here in Oracle is equivalent to an empty filename in another backend.
And, then, as documented null=True on CharFields.
Note that the docs say, "fields that have the empty string as a possible value", not specifically CharFields. This is because it also includes things like FileField, ImageField, CommaSeparatedIntegerField, GenericIPAddressField, etc.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment