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

  • Home
  • SEARCH
  • 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 899931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:18:09+00:00 2026-05-15T15:18:09+00:00

In a mini blog app, I want to create a delete function, so that

  • 0

In a mini blog app, I want to create a delete function, so that the owner of the blog can delete his entries (and only his entries).
I guess that the only methods for doing do, is using a form.
Though my the deletion code seems clear and correct, it doesn’t work.
My code:

def delete_new(request,id):
   u = New.objects.get(pk=id).delete()
   if request.method == 'POST':
       form = DeleteNewForm(request.POST)    
       form.u.delete()             
       form.save()   
   return render_to_response('news/deleteNew.html', {
           'form': form,
           }, 
        context_instance=RequestContext(request)) 

and in the template:

<a href='/news/delete_new/{{object.id}}/'> Delete</a> <br /> 

Is this a correct approach? I mean, creating a form for this?
also, the only way to take the blog post associated with the deletion link is having an id as a parameter. Is it right? I mean, maybe any user can type another id, in the url, and delete another entry (eventually not one of his)

  • 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-15T15:18:10+00:00Added an answer on May 15, 2026 at 3:18 pm

    In general, for deleting objects you should rather use POST (or DELETE) HTTP methods.

    If you really want to use HTTP GET for your example, here is what you need to fix:

    If you have url pointing to some url like yours: <a href='/news/delete_new/{{object.id}}/'> Delete</a> then you can simply write view that will check if object belongs to logged in user and delete this entry if yes, like in code you have already written:

    def delete_new(request,id):
       #+some code to check if New belongs to logged in user
       u = New.objects.get(pk=id).delete()
    

    To check if New objects belogs to some user you need to create realation between User and New (like created_by = models.ForeignKey(User) in New model).

    You can get logged in user this way: request.user

    I hope I got your point correctly and my answer helps you somehow.

    PS: You can also consider using {% url %} tag instead of writing urls directly in your templates.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I want to Create a home page that has updating blog entries. So
I have a mini blog app, and a reply system. I want to list
i have a mini blog app, and a 'timeline' . there i want to
in a mini virtual community, i have a profile_view function, so that i can
I want to make a 'timeline' containing all mini blog posts from a user,
I have a micro-mini-search engine that highlights the search terms in my rails app.
I have an App (Mini file manager) on my phone that has a button
function index() { $info['title'] = 'Browser Title'; $info['heading'] = 'Blog Heading'; $info['query'] = $this->db->get('entries');
Well i started coding a mini MVC base that I can just use on
I've read the blog post at letitcrash.com about Play-mini and Akka ( this one

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.