Let's say that I have a model:
class Ticket(models.Model):
client = models.ForeignKey(Client)
color = models.CharField(max_length=255)
def clean(self):
self.color = self.client.favorite_color
When I run this on the latest Django (head of the SVN from 15 minutes ago), if I hit save without selecting a client
, I get a DoesNotExist
error from inside my clean method (for the self.client.favorite_color
part). Since the model requires the client
attribute, shouldn't this be handled before my custom validation in clean()
?
Here's the documentation I'm reading: http://docs.djangoproject.com/en/dev/ref/models/instances/#id1