picture_url = models.CharField(max_length=2000)
views:
41answers:
2
A:
By default fields have null
set to False
try this
picture_url = models.CharField(max_length=2000, blank=True)
http://docs.djangoproject.com/en/1.1/ref/models/fields/#null
mountainswhim
2010-02-23 01:20:28
I don't think that's right. He wants to put null values in the column, but the database schema doesn't match. `blank=True` says "if you don't give me anything, I'll put a null value here". `null=True` says "this column can be null".
John Feminella
2010-02-23 01:23:04
That will work, but the Django specs say not to use `null=True` on String based values. Instead the field should be at the very least set to the empty string. I'm not sure what the repercussions are, but thats what the docs say. http://docs.djangoproject.com/en/1.1/ref/models/fields/#null
mountainswhim
2010-02-23 02:04:32
@mountainswhim » There aren't any "repercussions" per se, but it's considered a bad idea in general because now there's two ways to represent "no data" (`null` and `""`, the empty string). However, I find that the distinction is often useful: `null` can be taken to mean that _no data_ exists, while `""` means that the data exists, but has no value. For instance, in a culture that doesn't have middle names at all, a `middle_name` column for some people might be `null`; but in a different culture that does have middle names, this column might simply be blank for those without middle names.
John Feminella
2010-02-23 04:05:22
+3
A:
You'll need to add null=True
if the column can be null:
picture_url = models.CharField(max_length=2000, null=True)
John Feminella
2010-02-23 01:21:45