I'm working on learning Django, and I'm having trouble getting a basic "todo" app working.
I'm listing all my todo items in my template, with a checkbox next to each one for "done". I have an update button that goes to a view that updates all the item's done values. But, it's not working. It doesn't store my updates. I can edit it through the admin without problems, but I can't get it to work with my code. Here's my view: ********************* from django.shortcuts import render_to_response from django.http import Http404, HttpResponse, HttpResponseRedirect from django_test.todo.models import TodoItem def list(request): todos = [] for item in TodoItem.objects.all(): todo_dict = {} todo_dict['todo_title'] = item.Title todo_dict['todo_description'] = item.Description todo_dict['done'] = item.Done todo_dict['id']= item.id todos.append(todo_dict) return render_to_response(' todo.html', {'todos': todos}) def new(request): todo = TodoItem(Title=request.POST['Title'], Description=request.POST['Description'], Done=False) todo.save() return HttpResponseRedirect('/list/') def update(request): checked = request.POST.getlist('doneArray') for item in TodoItem.objects.all (): try: checked.index(item.id) item.Done=True except: item.Done=False item.save return HttpResponseRedirect('/list/') and here's my template code: ************ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd "> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>To-do List</title> </head> <body> <h1>To-do List</h1> <form action="/update/" method="post"> {% for item in todos %} <b>{{ item.todo_title }}</b> <br> <input type="checkbox" name="doneArray" value={{ item.id}} {% if item.done %} checked {% endif %}> {{ item.todo_description }} <br <br> {% endfor %} <input type="submit" value="Update"/> </form> <h2>Add new todo:</h2> <form action="/new/" method="post"> <b>Title: </b><input type="textfield" name="Title"/> <b>Description: <input type="textfield" name="Description"/> <input type="submit" value="New"/> </form> </body> </html> ************************************ What am I doing wrong? And is there a better way for me to check which item's done status has changed, besides iterating through my whole list of items? Thanks for any help you can give to a django newbie! --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---