Im trying to create view in which I can save templates as draft and Update the draft if its value is 1 or otherwise save a new document
I have the following Url configuration
url(r'^addprescription/(?P<pid>\d+)/$', views.viewtemplate, name='newtemplate')
for this view
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})`
Template
<a class="waves-effect waves-light btn right" href="{% url 'newtemplate' pid=patientid%} " >Add new </a>
Im getting the error
Reverse for 'newtemplate' with arguments '()' and keyword arguments '{'pid': ''}' not found. 1 pattern(s) tried: ['addprescription/(?P\d+)/$']
Django 1.10 Python 3.5 Windows 7