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

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

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 =

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

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

Re: how to enforce uniqueness

2009-01-18 Thread Malcolm Tredinnick
On Sun, 2009-01-18 at 09:58 -0700, Dj Gilcrease wrote: > On Sun, Jan 18, 2009 at 4:34 AM, Malcolm Tredinnick > wrote: > >> Right now, that is only enforced by the admin interface, > > > > I should have extended this to also say "and ModelForms", since if you > > create

Re: how to enforce uniqueness

2009-01-18 Thread Dj Gilcrease
On Sun, Jan 18, 2009 at 4:34 AM, Malcolm Tredinnick wrote: >> Right now, that is only enforced by the admin interface, > > I should have extended this to also say "and ModelForms", since if you > create a ModelForm from a Model, unique and unique_together are >

Re: how to enforce uniqueness

2009-01-18 Thread Malcolm Tredinnick
On Sun, 2009-01-18 at 22:32 +1100, Malcolm Tredinnick wrote: [...] > Have a look at unique_together: > http://docs.djangoproject.com/en/dev/ref/models/options/#unique-together > > Right now, that is only enforced by the admin interface, I should have extended this to also say "and ModelForms",

Re: how to enforce uniqueness

2009-01-18 Thread Malcolm Tredinnick
On Sun, 2009-01-18 at 02:40 -0800, Konstantin wrote: > Hello! > > First of all I want to apologize for maybe very basic question, but I > newbie in django and web coming from c/c++ world. > > I have two models: > > class Box(models.Model): > description = models.CharField(max_length=250) >

Re: how to enforce uniqueness

2009-01-18 Thread phoebebright
Maybe this would help? http://docs.djangoproject.com/en/dev/ref/models/options/#unique-together On Jan 18, 10:40 am, Konstantin wrote: > Hello! > > First of all I want to apologize for maybe very basic question, but I > newbie in django and web coming from c/c++ world. >

how to enforce uniqueness

2009-01-18 Thread Konstantin
Hello! First of all I want to apologize for maybe very basic question, but I newbie in django and web coming from c/c++ world. I have two models: class Box(models.Model): description = models.CharField(max_length=250) id = models.IntegerField(primary_key=True) def