我试图从 html 文件传递一个变量并试图在我的视图中访问它..但我得到了这个错误..--signup_vol_position 完全需要 2 个参数(给定 1 个)
视图.py
def signup_vol_position(request,comments):
pdb.set_trace()
if request.method == 'POST':
print('if')
else:
print('else')
teamrel = VolunteerRequirement.objects.values_list('teamrelation',flat=T
vollist = VolunteerRequirement.objects.order_by('teamrelation')
variable = RequestContext(request, {'vollist': vollist,'teamrel':teamrel
return render_to_response('signups/volunteer_list.dmpl',variable)
#variable = RequestContext(request,{'comments':comments}
#return render_to_response('sfp.view',variable)
.html 文件
<table>
{% for v in vollist %}
{% ifchanged v.teamrelation %}
<tr>
<th colspan=7 align="left"><h3><a name="{{ v.teamrelation }}"> {{v.teamrelation}} </a> </h3></th>
</tr>
{% endifchanged %}
<tr>
<th colspan=4 align="left"><label for="id_Volposition">Volunteer Position:</label></th>
<th colspan=.5 align="left"><a href="/signups/volposition/{{ v.position }}" class="username" <u>{{ v.volposition }}</u></a></th>
<tr> <td colspan="2" height="2" style="display:none"> </td> </tr>
</tr>
网址.py
urlpatterns = patterns('',
(r'^new/$', sfp.view),
(r'^volunteer/$', volunteer_page),
(r'^vollist/$', volunteer_list),
(r'^volcont/$', volunteer_contact),
(r'^volposition/$',signup_vol_position)
)