Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3360974
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:04:57+00:00 2026-05-18T03:04:57+00:00

I have a template that displays a list of objects from the database. {%

  • 0

I have a template that displays a list of objects from the database.

{% for item in items %}
<li>
    {{ item }} - Tags: 
    {% for tag in item.tags.all %}
        <a href="/{{ user }}/{{ tag }}/">{{ tag }}</a>
    {% endfor%}
<br>
{{ item.notes }}
<br>
{{ item.date_modified|humanize_time_diff }}
<a href="">delete</a>
</li>
{% endfor%}

How can I allow a user to delete one of these objects, while staying on the same page?

Here is my view function:

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T03:04:58+00:00Added an answer on May 18, 2026 at 3:04 am

    It’s a simple, but longer story. To make it short, you can check this article: http://www.arnebrodowski.de/blog/484-Django-Ajax-comment-deletion.html which contains a snippet (written with YUI, but its jQuery counterpart would be very similar: http://api.jquery.com/jQuery.ajax/) that performs AJAX query, which in turn deletes a comment.

    The comment deletion view is built into django.contrib.comments.views, and you have to write your own view for deleting tags. It should look roughly like this:

        def delete_tag_view(request, tag):
            tag_to_delete = get_object_or_404(Tag, title=tag)
            tag_to_delete.delete()
            return HttpResponse('OK') # This should really return JSON and/or some relevant HTTP status code
    

    Of course, you need to hook this into your URLconf:

    url(r'/tag/delete/(?P<tag>\w+)', 'tags.views.delete_tag_view', name='tag-delete')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a template that displays the list of items. It has one checkbox
I have a gridview that displays items details, I added two template fields one
I'm making a generic template that will be displaying a list of objects from
I have a template that displays the titles of a custom post type. I
I have a Silverlight DataGrid that contains a single template column which displays a
I am new to the Django web framework. I have a template that displays
Ok, currently I have a view in my android app that displays a list
I have a list of item which only displays the latest status of each
I have a class that gathers templates and displays the final output after connecting
I have a smarty template, that I want to display a random sentence on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.