Question: I'm new to django and for practice I'm trying to program my own version of the all familiar 'todo list' app.

I have some page that displays all todo list items the user has entered, along with a button to edit each one. The edit button sends the user to another page with a form to enter in the changes to the item. 

It's possible for the user to change everything about the item. Obviously request.POST gives me all the information the user just put into the form, but I want this information to rewrite the info of the item they originally clicked on. So how do I write the view code to find out what that original item was?

I guess I could format my form submit button to:

> 
> `<button type="submit" name="save" value={{ item.pk }}>Save</button>` 
> 
> 
> 

and get the primary key that way

but lets say I had passed two items to the edit page and I wanted to give the user the ability to combined them. Again, I *could* figure out what those items were by doing:

> 
> `<button type="submit" name="save" value='{{ item1.pk }} {{ item2.pk }}'>Save</button>`
> 
> 
> 

then

> 
> `request['save'].split(' ')`
> 
> 
> 

this seems kinda stupid though. Is there some other, less brute force, way?

like a:

> 
> request.tell\_me\_all\_items\_passed\_to\_the\_template
> 
> 
> 

kind of thing?

Answer: 
In case someone else has the same question

**So instead of doing this:**

*template* 

```
<form method="post" action="/list/saving/">
    <!--- form fields --->
    <button type="submit" name="save" value='{{ item.pk }}'>Save</button>
</form>

```

*url.py*

```
(r'^list/saving/$', save)

```

*views.py*

```
def save(request):
    ....
    item = Item.objects.get(pk=request.POST['save'])
    ....

```

**do this:**

*template*

```
<form method="post" action="{% url todolist.views.save item.pk %}">
    <!--- form fields --->
    <button type="submit" name="save">Save</button>
</form>

```

*url.py*

```
(r'^list/saving/(\d+)/$', save)

```

*views.py*

```
def save(request, pk):
    ....
    item = Item.objects.get(pk=pk)
    ....

```

[More info on url reversing](https://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#url)
If you really need to, just use hidden inputs. But, this is unnecessary anyways. The user may be able to change "everything" about the item, but they can't change the `pk` (or at least they *shouldn't* be able to... don't give them the option to). The `pk` is what Django uses to identify an object, so this is already handled for you. Not sure what the issue here is.