I am attempting to make a simple Todo site that allows you to record todos and mark them as done. The problem I am having is with the urls. 

When you first go to localholst:8000/todo/ everything is fine and it shows all of my todos. I now want to be able to check the checkbox next to one and have the list automatically update with that todo crossed out. When you do this from localhost:8000/todo/ it works fine **BUT** you are left in the localhost:8000/todos/check/3 url (this url allows me to trap this view through a regexp url to update the database with that todo item as being clicked).

**Problem:** If I then click another todo item to mark it as done, it does not work. If I attempt to click on the todo item with id=4, my URL is localhost:8000/todos/check/3/check/4. You can see that after I did it once, it used the url to catch the view that updates the database, but then it should have sent the user back to localhost:8000/todo/ to set up for the next check. Instead, it left us at localhost:8000/todos/check/3 and added on "/check/4" to the end of it.

**Question:** How can I lose the "check/3" from the url after I have handled the actual update to the database?

*My main urls.py (which points to my todo/urls.py file):*

```
from django.conf.urls import patterns, include, url

urlpatterns = patterns('',
    url(r'^admin/', include(admin.site.urls)),
    url(r'^todo/', include("todo.urls", namespace="todo")),
)

```

*My todo/urls.py file:*

```
from django.conf.urls import patterns, url
from todo import views

urlpatterns = patterns('',                 
    url(r'^add/$', views.add, name='add'),
    url(r'^remove/$', views.remove_done, name='remove'),
    url(r'^check/(?P<todo_id>\d+)/$', views.check, name='check'),

    url(r'^$', views.index, name='index'),
)

```

*The views.py (truncated)*

```
from todo.models import todo

def index(request):
    todos_done = todo.objects.filter(done = True) # @UndefinedVariable
    todos_not_done = todo.objects.filter(done = False)
    total_todos = todos_done.count() + todos_not_done.count()

    return render(request, 'todo/index.html', { 'todos_done': todos_done, 'todos_not_done': todos_not_done, 'total': total_todos })

def check(request, todo_id):
    todo_to_mark = todo.objects.get(id=todo_id) # @UndefinedVariable

    if todo_to_mark.done == True:
        todo_to_mark.done = False
    else:
        todo_to_mark.done = True
    todo_to_mark.save()

    todos_done = todo.objects.filter(done = True)
    todos_not_done = todo.objects.filter(done = False)
    total_todos = todos_done.count() + todos_not_done.count()

    return render(request, 'todo/index.html', { 'todos_done': todos_done, 'todos_not_done': todos_not_done, 'total': total_todos })

```

And finally, my templates/todo/index.html file (truncated)

```
    <div>
    <span>{{ todos_done|length }} of {{ total }} remaining</span>
    [ <a href="{% url 'todo:remove' %}">Clear all done</a> ]

    <ul class="unstyled">
        {% for todo in todos_done %}
            <li>
                <input type="checkbox" name="todo{{todo.id}}" id="{{todo.id}}" onchange="todoChecked({{todo.id}})" checked>
                <span class="done-true">{{ todo.todo_text }}</span>
            </li>
        {% endfor %}

        {% for todo in todos_not_done %}
            <li>
                <input type="checkbox" name="todo{{todo.id}}" id="{{todo.id}}" onchange="todoChecked({{todo.id}})" >
                <span>{{ todo.todo_text }}</span>
            </li>
        {% endfor %}
    </ul>

    <form action="{% url 'todo:add' %}" method="post">
    {% csrf_token %}
        <input type="text" size="30" name="new_text" id="new_text" placeholder="Add new todo here">
        <input class="btn-primary" type="submit" value="Add">
    </form>

    <!-- Javascript function -->
    <script>
        function todoChecked(todo_id) {
            window.open("../todo/check/" + todo_id); 
        }
    </script>
</div>

```