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 <tevans...@googlemail.com> wrote:
> On Thu, Apr 22, 2010 at 2:45 PM, Radhikavk <radhi3...@gmail.com> 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 sorry, Dave. I'm afraid I can't do that")
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to