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 <radhi3...@gmail.com> wrote:
> Model
>
> class mdlcountry(models.Model):
>     class Meta:
>         verbose_name_plural = "Countries"        
>     country_id = models.AutoField(primary_key=True,null=False,blank=False)
>     country_name =
> models.CharField(max_length=100,unique=True,null=False,blank=False,verbose_name='Country
> Name')
>
>     def save(self, *args, **kw):
>        super(mdlroomtypes, self).save(*args, **kw)
>
>     def __str__(self):
>         return self.country_name
>
> How to raise error if india country name alredy exists in database and again
> the user is trying to insert india.
>
> Regards
> radhika
> --
> View this message in 
> context:http://old.nabble.com/How-to-raise-integrity-error-in-save-method-of-...
> Sent from the django-users mailing list archive at Nabble.com.
>
> --
> 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