Hi

I am trying to make sense of Django's form capabilities, having only
done ajax posts before..

Before ajaxification:

<form action="/add_person/" method="POST">
    {{ form.as_p }}
    <input type="submit" value="Submit" />
</form>

def add_person(request):
    form = PersonForm(request.POST)
    if form.is_valid():
        Person.objects.create(name=form.cleaned_data['name'])
        return HttpResponseRedirect('/people/')

After ajaxification:

<label for="name">Name:</label>
<input id="name" name="name" />
<button onClick="submit(this)" type="submit">submit</button>

p = Person.objects.create(name=request.POST['name'])
data = json.dumps({ 'name': p.name })
return HttpResponse(data, mimetype="application/javascript")

So my question is, is it worth using all the Django gubbins when the
alternative appears very simple?

Thanks!
Darren

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to