Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. class Non_ONCO(CommonField):
  2.      
  3.      def clean(self):
  4.           if not self.id:
  5.                slug = slugify(self.libelle)
  6.                if Non_ONCO.objects.filter(slug_libelle=slug).exists():
  7.                     raise ValidationError(u"Ce libellé existe déjà")
  8.  
  9.      def save(self,force_insert=False,force_update=False):
  10.           self.slug_libelle = slugify(self.libelle)
  11.           super(Non_ONCO,self).save(force_insert=False,force_update=False)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement