python - Django : multi variables in urls.py not working -
i'm trying construct url 2 variables in template, yet same error message. i'm quite new djang , drives me quite nuts, need :)
exception type: noreversematch exception value: reverse 'skill_update' arguments '()' , keyword arguments '{u'instancepk': 1, u'skillpk': 15}' not found. 1 pattern(s) tried: [u'persomaker/skill/update/(?p<skillpk>[0-9]+)$/(?p<instancepk>[0-9]+)$']
template :
{% url 'persomaker:skill_update' skillpk=item.pk instancepk=instance.pk %}
view.py :
def skill_update(request,skillpk,instancepk): form = skillcreateform(request.post) user = user.objects.get (id = request.user.id) instance = character.objects.get (id = instancepk) if form.is_valid(): form.save() return redirect('persomaker:skill_list', instance.id) else: skill = skill.objects.get(id=pk) form = skillcreateform(initial={'character':instance}) form.fields['skill'].widget = hiddeninput() form.fields['level'].queryset = range(0,7) form.fields['character'].widget = hiddeninput() return render(request, 'character/create_skill.html', {'instance':instance, 'form': form,})
url.py :
url(r'^skill/update/(?p<skillpk>[0-9]+)$/(?p<instancepk>[0-9]+)$', views.skill_update, name='skill_update'),
you have $
in middle of pattern regex. that's terminating character; nothing after ever match. remove 1 in middle.
Comments
Post a Comment