Re: how to capture the exception

2010-02-25 Thread Karen Tracey
On Wed, Feb 24, 2010 at 5:13 PM, bruno desthuilliers < bruno.desthuilli...@gmail.com> wrote: > But anyway: you already specified the unique constraint in the 'name' > field definition, so adding this code in your model save() method is > just useless - the uniqueness constraint WILL be applied at

Re: how to capture the exception

2010-02-24 Thread bruno desthuilliers
On 24 fév, 21:11, harryos wrote: > sorry, > missed while copying > > def save(self): >       self.name=self.name.strip() >       if (not self.pk): >           if Article.objects.filter(name__iexact=self.name).count()! > =0: >               raise Exception('article exists..') Now this will only

Re: how to capture the exception

2010-02-24 Thread harryos
sorry, missed while copying def save(self): self.name=self.name.strip() if (not self.pk): if Article.objects.filter(name__iexact=self.name).count()! =0: raise Exception('article exists..') this causes 500 error,and causes the traceback displayed on browser..h

Re: how to capture the exception

2010-02-24 Thread Shawn Milochik
Note: As written, your code will never let you edit an existing Article. You should add an if statement to check whether 'self.pk' is true also. Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to djang

how to capture the exception

2010-02-24 Thread harryos
hi In my models save() method I want to check if an Article with same name already exists. class Article(Model): name=models.CharField(max_length = 1024, unique = True) def save(self): self.name=self.name.strip() if Article.objects.filter(name__iexact=self.name).count()!=0: