<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def tag_lookup(request):
 """JSON endpoint that returns a list of potential tags. Used for upload template autocomplete. """

    tag = request.GET['tag']
    tagSlug = slugify(tag.strip())
    tagCandidates = Tag.objects.values('word').filter(slug__startswith=tagSlug)
    tags = json.dumps([candidate['word'] for candidate in tagCandidates])
    return HttpResponse(tags, content_type='application/json')