On Wednesday, January 5, 2011 3:30:42 AM UTC-5, Valts wrote: > > Just my $0.02: I think that such feature would be useful when using > get_or_create() when I don't want the object to be saved into the > database if it does not validate. There could be added another special > keyword argument "full_clean", "validate" or similar to > get_or_create(). If the proposed idea gets the green light I am > willing to create the ticket and the necessary patches. >
While I tend to agree that it would be nice to have an option to validate models before saving automatically, it's super easy to add yourself using the pre_save signal: from django.db.models.signals import pre_save def validate_model(sender, **kwargs): if 'raw' in kwargs and not kwargs['raw']: kwargs['instance'].full_clean() pre_save.connect(validate_model, dispatch_uid='validate_models') Dan -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-develop...@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.