Lets say I have a model defined as follows:
class Foo(models.Model):
bar = models.CharField(max_length=10)
Using this model, I create a Foo
object in my database using the following code:
Foo.objects.create(bar="0123456789")
Should work well enough. However, after creating the object, I reduce the max_length
property to 5. So now, technically, the object I created has a consistency error.
How does Django manage a situation like this? I assume they don't raise any errors until that object is saved again. If so, is that the optimal solution for a situation like this, and are there are any other approaches?