Python-Django Response the text of error
<p>How can I response the text of validation error to my template with Ajax?</p>

<pre><code>def create_user(request):
    if request.method == 'POST':
        is_super = True
        if request.POST.get('is_super') in 'false':
            is_super = False
        if request.POST.get('password') == request.POST.get('confirm'):
            user = User.objects.create(first_name=request.POST.get('first_name'),
                                       last_name=request.POST.get('second_name'),
                                       username=request.POST.get('username'),
                                       is_superuser=is_super,
                                       date_joined=datetime.now())
            user.set_password(request.POST.get('password'))
            user.save()
        else:
            raise forms.ValidationError("Passwords doesn't match")
        return HttpResponse('')
</code></pre>

<pre><code>def create_user(request):
    if request.method == 'POST':
        is_super = True
        if request.POST.get('is_super') in 'false':
            is_super = False
        if request.POST.get('password') == request.POST.get('confirm'):
            user = User.objects.create(first_name=request.POST.get('first_name'),
                                       last_name=request.POST.get('second_name'),
                                       username=request.POST.get('username'),
                                       is_superuser=is_super,
                                       date_joined=datetime.now())
            user.set_password(request.POST.get('password'))
            user.save()

        else:
            return HttpResponse(json.dumps({'error': True, 'message': 'Password and confirm password doesnt match'}))`            
        return HttpResponse('')
</code></pre>

<p>You need to show the above error message "Password and confirm password doesn't match" in HTML using Jquery.</p>

python ajax django