案例我在 /notes/get/1/ 中,其中 id=1 并且我在 note.html 中创建了一个“删除笔记”链接。我需要它从数据库和应用程序中删除当前笔记并重定向到 /notes/all。你能帮我解决def delete中的代码吗?
模型.py:
class Note(models.Model):
title = models.CharField(max_length=200)
body = models.TextField()
cr_date = models.DateTimeField(auto_now_add=True)
网址.py:
urlpatterns = patterns('',
url(r'^all/$', 'note.views.notes'),
url(r'^get/(?P<note_id>\d+)/$', 'note.views.note'), #
url(r'^language/(?P<language>[a-z\-]+)/$', 'note.views.language'), #
url(r'^create/$', 'note.views.create'),
url(r'^delete/$', 'note.views.delete'), <--------------------------
url(r'^search/$', 'note.views.search_titles'),
)
视图.py:
def delete(??????):
????? <-------------------------------------------
return HttpResponseRedirect('/notes/all')