def is_user_exists(request):
"""
Checks if user is exists. If exists return True, else False.
"""
if request.is_ajax():
is_user_exists_form = IsUserExistsForm(request.GET)
if is_user_exists_form.is_valid():
try:
User.objects.get(username=is_user_exists_form.cleaned_data['username'])
return HttpResponse(json.dumps(True), content_type='application/json')
except ObjectDoesNotExist:
return HttpResponse(json.dumps(False), content_type='application/json')
else:
return HttpResponse(status=404)
# ----------------------------------------------------------------------------------------------------------------------
评论列表
文章目录