(self, slug)
Adds a (non-cannonical) slug
Adds a (non-cannonical) slug
Adds a ( non - cannonical ) slug
def add_slug(self, slug):
        """Adds a (non-cannonical) slug"""

        if not slug:
            raise ValueError("'%s' is not a valid slug" % slug)

        existing_slugs = self.slugs.all()

        # cut slug to the maximum allowed length
        slug = utils.to_maxlength(Slug, "slug", slug)

        # check if slug already exists
        if slug in [s.slug for s in existing_slugs]:
            return

        max_order = max([-1] + [s.order for s in existing_slugs])
        next_order = max_order + 1
        Slug.objects.create(
            scope=self.scope, slug=slug, content_object=self, order=next_order
        )
def add_slug ( self , slug ) : if not slug : raise ValueError ( "'%s' is not a valid slug" % slug ) existing_slugs = self . slugs . all ( ) # cut slug to the maximum allowed length slug = utils . to_maxlength ( Slug , "slug" , slug ) # check if slug already exists if slug in [ s . slug for s in existing_slugs ] : return max_order = max ( [ - 1 ] + [ s . order for s in existing_slugs ] ) next_order = max_order + 1 Slug . objects . create ( scope = self . scope , slug = slug , content_object = self , order = next_order )