My question is, what is the best practice for turning a null=True
field into a null=False
field using Django South. Specifically, I'm working with a ForeignKey
.
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Django __str__ returned non-string (type NoneType)
- Evil ctypes hack in python
If you want to turn nullable ForeignKey into non-nullable one, then it can be problematic if you have any rows with NULL for that field (column). In such case you need to either remove or fix them - possibly with custom data migration, like
diegueus9
mentioned in the other answer.But if you don't have any rows with NULL in that column, e.g. because you put that null=True only in case you might need it in the future, then you should be able to do a simple automatic schema migration:
You should write first a data migration: http://south.aeracode.org/docs/tutorial/part3.html and then make the schemamigration.