views.py
def updateKwalificatie (request, pk):
kwalificatie = Kwalificaties.objects.get(id=pk)
form = kwalificatie_beheer(instance=kwalificatie)
context = {'form': form}
return render(request,'accounts/kwalificatiebeheer.html', context)
urls.py
path('updateKwalificatie/<str:pk>/', views.updateKwalificatie, name='updatekwalificatie'),
kwalificaties.html tamplate
<div class="card card-body">
<table class="table table-sm">
<tr>
<th>ID</th>
<th>E.H.B.O</th>
<th>Treinen</th>
<th>Extra</th>
<th>update</th>
<th>verwijder</th>
</tr>
{% for i in kwalificaties %}
<tr>
<td>{{i.naam}}</td>
<td>{{i.ehbo}}</td>
<td>{{i.treinen}}</td>
<td>{{i.extra}}</td>
<td><a class="btn btn-sm btn-outline-secondary" href="{% url 'updatekwalificatie' kwalificatie.id %}">Update</a></td>
<td><input type="submit" value="Verwijder"></td>
</tr>
{% endfor %}
heyi hope someone can help me with this error thx alot.....................................................................
CodePudding user response:
When you loop over kwalificaties
in your template you name the loop variable/instance i
, you need to use this name in your tag or change i
to kwalificatie
{% for i in kwalificaties %}
<tr>
<td>{{i.naam}}</td>
<td>{{i.ehbo}}</td>
<td>{{i.treinen}}</td>
<td>{{i.extra}}</td>
<td><a class="btn btn-sm btn-outline-secondary" href="{% url 'updatekwalificatie' i.id %}">Update</a></td>
<td><input type="submit" value="Verwijder"></td>
</tr>
{% endfor %}