我试图创建一个视图,我可以将模板保存为草稿,如果其值为1则更新草稿或以其他方式保存新文档
我有以下网址配置
url(r'^addprescription/(?P<pid>\d+)/$', views.viewtemplate, name='newtemplate')
此视图
def viewtemplate(request, pid):
patient = Patient.objects.get(patientid=pid)
#form = templateform(request.POST)
if request.method == "POST":
if presciptiontemplates.draft == 1:
form = newpatientform(request.POST, instance=patient)
if form.is_valid():
form = form.save(commit=False)
form.patientid = pid
form.save()
messages.success(request, 'Form submission successful')
return redirect('index')
else:
form = templateform(request.POST)
if form.is_valid():
form = form.save(commit=False)
form.patientid = pid
form.save()
return redirect('index')
else:
form = templateform()
return render(request, 'presapp/prescription.html', {'form': form})`
模板
<a class="waves-effect waves-light btn right" href="{% url 'newtemplate' pid=patientid%} " >Add new </a>
我得到了错误
反向'newtemplate',参数'()'和关键字参数'{'pid':''}'找不到。尝试了1种模式:['addprescription /(?P \ d +)/ $']
Django 1.10 Python 3.5 Windows 7