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
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
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
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
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,
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
6 matches
Mail list logo