If you must use ajax for this, then I recommend using jQuery's $.ajax() function. This page has a good writeup on django + ajax which helped me a lot.
You don't need ajax for this though. You can avoid forms if you really want to but not template tags. I think this should do what you want, or at least push you in the right direction.
# views.py
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render
from newsletter.models import Member
def subscribe(request):
if request.method == 'POST'
fullname = request.POST['name']
email = request.POST['email']
very_exist = [m.email for m in Member.objects.all()]
if email in very_exist:
error = "Votre adresse email est déjà inscrite à la newsletter."
return HttpResponse({'error': error})
# return render(request, 'base.html', {'error': error}) # or this, I'm not sure
new_subscriber = Member(fullname=fullname, email=email)
new_subscriber.save()
return HttpResponseRedirect('/success/')
return render(request, 'base.html')
And somewhere in base.html:
{% if error %}
<p class='error-msg'>{{ error }}</p>
{% endif %}