Like in django you can implement the removal of posts on my blog?

I write the blog I want to implement delete posts through the form how can I do that?
July 12th 19 at 16:53
2 answers
July 12th 19 at 16:55
Not sure that's the best solution but will work.

  • Project - the project name
  • blog - the name of the app
  • Post the name of the model
  • is id advisable to use a slug
  • the link "delete" to hang on the button.

from django.shortcuts import get_object_or_404
from django.core.urlresolvers import reverse

def delete(request, id):
 post = get_object_or_404(Post, id=id).delete() 
 return HttpResponseRedirect(reverse(''))

July 12th 19 at 16:57
What exactly does not work? You don't know how to do? The vyuha?
If in General: geom submit the form, post accept, if rest, the he. In the vyuha removed. What's the problem then?
Can you tutorial pass gange? There are:технологии-154
Any way, such questions will disappear.

Find more questions by tags DjangoPython