我需要將一個動態變量放入django表單上的地址。 形式是:django:如何將動態變量添加到HTML中的地址?
<form action='/disciplinas/{{disciplina_id}}/edit/' method='submit'>{% csrf_token %}
<input type='submit' value='Voltar'>
</form>
的問題是在哪裏我寫的「{{disciplina_id}}」,我怎麼能代表「動作」?
view.py功能
def detail(request, disciplina_id):
nome = disciplina.objects.filter(id__exact=disciplina_id)
if request.method == 'POST':
return HttpResponseRedirect('^(?P<disciplina_id>\d+)')
if request.method == 'POST':
nome.delete()
return HttpResponseRedirect('/disciplinas/success')
return render_to_response('/home/zephir/Template/disciplinas/detail.html', {'nome': nome}, context_instance=RequestContext(request))
更新您的文章在views.py您的視圖功能 –