title: Delete an object with AJAX/jQuery in Django
body: <p>I have a template that displays a list of objects from the database. </p>
  
  <pre><code>{% for item in items %}
  &lt;li&gt;
      {{ item }} - Tags: 
      {% for tag in item.tags.all %}
          &lt;a href="/{{ user }}/{{ tag }}/"&gt;{{ tag }}&lt;/a&gt;
      {% endfor%}
  &lt;br&gt;
  {{ item.notes }}
  &lt;br&gt;
  {{ item.date_modified|humanize_time_diff }}
  &lt;a href=""&gt;delete&lt;/a&gt;
  &lt;/li&gt;
  {% endfor%}
  </code></pre>
  
  <p>How can I allow a user to delete one of these objects, while staying on the same page?</p>
  
  <p>Here is my view function:</p>
  
  <pre><code>def tag_page(request, username, tag=None):
  if username == request.user.username:
      if tag and tag in request.user.userprofile.tag_set.all():
          tag = Tag.objects.get(title=tag)
          items = tag.item_set.all()
          return render_to_response("tag_page.html", { 'user': request.user , 
                                                        'tag': tag,
                                                      'items': items })
      else:
          items = request.user.userprofile.item_set.all()
          return render_to_response("tag_page.html", { 'user': request.user , 
                                                        'tag': tag,
                                                      'items': items })
  else:
      raise Http404
  </code></pre>