On Thu, Apr 22, 2010 at 2:22 PM, ge...@aquarianhouse.com <ge...@aquarianhouse.com> wrote: > def save(self, *args, **kw): > if not > mdlcountry.objects.filter(country_name=self.country_name).exists(): > super(mdlroomtypes, self).save(*args, **kw) > else: > #do something or do nothing > pass >
Er, yeah, as long as you wish to do a lookup before you save any record - seems a bit redundant to me when you can just mark the field as unique in the database. Your country field does already have unique in it - did you add that *after* you had created the table (after you ran manage.py syncdb)? Otherwise you would already have the behaviour you requested. Cheers Tom -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.