Python taggit.models.TagBase() Examples
The following are 1
code examples of taggit.models.TagBase().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
taggit.models
, or try the search function
.
Example #1
Source File: tags.py From wagtail with BSD 3-Clause "New" or "Revised" License | 6 votes |
def autocomplete(request, app_name=None, model_name=None): if app_name and model_name: try: content_type = ContentType.objects.get_by_natural_key(app_name, model_name) except ContentType.DoesNotExist: raise Http404 tag_model = content_type.model_class() if not issubclass(tag_model, TagBase): raise Http404 else: tag_model = Tag term = request.GET.get('term', None) if term: tags = tag_model.objects.filter(name__istartswith=term).order_by('name') else: tags = tag_model.objects.none() return JsonResponse([tag.name for tag in tags], safe=False)