我一直在做一个项目,但我无法向edit.html和details.html发布请求。
这是我的代码:
dog_app / urls.py
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$',views.index),
url(r'^create$',views.create),
url(r'^edit/(?P<id>\d+)$', views.edit),
url(r'^(?P<id>\d+)/details/$', views.details),
]
views.py
from django.shortcuts import render,redirect
from models import Dog
def edit(request, id):
dog=Dog.objects.get(id=id)
context={'dog': dog}
return render(request,'dog_app/edit.html',context)
def details(request, id):
dog=Dog.objects.get(pk=id)
context={"dog": dog}
return render(request,'dog_app/details.html',context)