Re: How to enforce uniqueness based on two model fields

2009-10-19 Thread Shawn Milochik
Guillermo, Please see the 'unique_together' syntax: http://docs.djangoproject.com/en/dev/ref/models/options/#unique-together --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this g

Re: How to enforce uniqueness based on two model fields

2009-10-18 Thread Guillermo
Thanks, Mihail! Sometimes I don't know where to look for what I need, but the docs are indeed stellar! On Oct 18, 8:24 pm, Михаил Лукин wrote: > http://docs.djangoproject.com/en/dev/ref/models/options/#unique-together > why don't you like to read docs first. Django docs are amazing! > > 2009/10/

Re: How to enforce uniqueness based on two model fields

2009-10-18 Thread Михаил Лукин
http://docs.djangoproject.com/en/dev/ref/models/options/#unique-together why don't you like to read docs first. Django docs are amazing! 2009/10/18 Guillermo > > Ok I've done the following: > > def save(self): >r = TargetMessage.objects.filter(src_fk=self.src_fk, >

Re: How to enforce uniqueness based on two model fields

2009-10-18 Thread Guillermo
Ok I've done the following: def save(self): r = TargetMessage.objects.filter(src_fk=self.src_fk, lang_fk=self.lang_fk) if not r: super(TargetMessage, self).save() How can I propagate a validation error to the admin interface

How to enforce uniqueness based on two model fields

2009-10-18 Thread Guillermo
Hi all, I want my records to be unique for field A and B together, so that no two records can share the same values for those particular fields. How can this be declared in the model? Regards, Guillermo --~--~-~--~~~---~--~~ You received this message because you a