Re: How to raise integrity error in save method of model

2010-04-22 Thread ge...@aquarianhouse.com
In this case it's the wrong place, you have to put the logic into the form class MyForm(models.ModelForm): model = mdlcountry def country_name(self): #verify here and give an error On Apr 22, 3:51 pm, Tom Evans wrote: > On Thu, Apr 22, 2010 at 2:45 PM, Radhikavk wrote: > > > i hav

Re: How to raise integrity error in save method of model

2010-04-22 Thread Tom Evans
On Thu, Apr 22, 2010 at 2:45 PM, Radhikavk wrote: > > i have defined the country field unique in database but when i try to insert > duplicate entry it throws an error , to handle that error i m asking In your view: try: instance.save() except IntegrityError, e: return HttpResponse("I'm sorr

Re: How to raise integrity error in save method of model

2010-04-22 Thread Radhikavk
i have defined the country field unique in database but when i try to insert duplicate entry it throws an error , to handle that error i m asking -- View this message in context: http://old.nabble.com/How-to-raise-integrity-error-in-save-method-of-model-tp28328713p28329111.html Sent from the dja

Re: How to raise integrity error in save method of model

2010-04-22 Thread Radhikavk
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 Here in else part how will i set error message that should display to the us

Re: How to raise integrity error in save method of model

2010-04-22 Thread Tom Evans
On Thu, Apr 22, 2010 at 2:22 PM, 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,

Re: How to raise integrity error in save method of model

2010-04-22 Thread ge...@aquarianhouse.com
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 On Apr 22, 3:14 pm, Radhikavk wrote: > Model > > class mdlcountry(models.Model