def get_queryset(self): """Query set selection""" queryset = self.queryset keywords = self.request.query_params.get("keywords", None) if keywords: queryset = queryset.filter(slug__icontains=slugify(keywords)) return queryset
def make_slug(value): """Generate Category slug""" i = 0 while i >= 0: slug = slugify((value + (str(i) if i else "")).lower()) count = Category.objects.filter(slug=slug).count() if not count: return slug
def post_slug_generate(title): i = 0 while i >= 0: slug = slugify((title + (str(i) if i else "")).lower()) if not Post.objects.filter(slug=slug).count(): return slug
def slug_generate(title): i = 0 while i >= 0: slug = slugify(title) if not Tag.objects.filter(slug=slug).count(): return slug