Question: I have the following template, which has both an "add" and "delete" button:

```
<tr>
    <td>Position</td>
    <td>{{ form.position }}<input type="submit" value="add" , name='add'/></td>
</tr>
<tr>
    <td> </td>
    <td>
        {% for position in positions %}
        {{ position}}<input type="submit" value="Delete", name="delete-position.{{ position }}"/> 
        {% endfor %}
    </td>
</tr>

```

How would I construct the views.py function to find the `name` value of the Delete submit button? I currently have: 

```
    try:
        request.POST['add']
        positions.append(request.POST['position'])          
        return render_to_response('registration/getting_started_info1.html', {'form': form, 'positions': positions}, context_instance = RequestContext(request))
    except: 
        if 'delete-position' in request.POST:
            positions.remove(### how to get name of Delete submit? ###)
            return render_to_response('registration/getting_started_info1.html', {'form': form, 'positions': positions}, context_instance = RequestContext(request))

```

Also, is there a better way to construct the view/template so I can use an `if...else` instead of a `try...except` ?

Answer: 
First, you should probably do this:

```
if request.method == "POST":
    if 'add' in request.POST.keys():
        positions.append(...)
        return render_to_response(...)
    else:
        for k, v in request.POST.items():
            if k.startswith('delete-position'):
                positions.remove(k)
                return render_to_response(...)

```

That should help with what you're asking... however, I'm not sure if it's the easiest method to do what you're trying to do.
Your try-catch is kind of weird. You should probably be submitting delete requests to a different view.

But as to how you can get the `delete-position` vars, it's easy:

```
def delete(request):
    if request.method == "POST":
        for key in request.POST.keys():
            if key.startswith('delete-position'):
                positions.remove(request.POST[key])

```