Adding page for editing person data
This commit is contained in:
parent
5a0c724591
commit
cfafc0f226
3
member/static/icons/heroicons/pencil.svg
Normal file
3
member/static/icons/heroicons/pencil.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L6.832 19.82a4.5 4.5 0 0 1-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 0 1 1.13-1.897L16.863 4.487Zm0 0L19.5 7.125" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 362 B |
@ -1,5 +1,6 @@
|
||||
{% extends "master.html" %}
|
||||
{% load static %}
|
||||
{% load svg %}
|
||||
|
||||
{% block title %}
|
||||
List of all persons
|
||||
@ -22,7 +23,7 @@
|
||||
<tr>
|
||||
<td><a href="{% url 'details' x.id %}"><img src="{% static 'icons/arrow-right.svg' %}" class="icon">{{ x.nachname }} {{ x.vorname}}</a> </td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td><a href="{% url 'edit' x.id %}" title="Bearbeiten"><img src="{% static 'icons/heroicons/pencil.svg'%}" class="icon"></a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
||||
@ -5,4 +5,5 @@ urlpatterns = [
|
||||
path('members/', views.members, name='members'),
|
||||
path('members/details/<int:id>', views.details, name="details"),
|
||||
path('members/create/', views.create, name="create"),
|
||||
path('members/edit/<int:id>', views.edit, name="edit"),
|
||||
]
|
||||
|
||||
@ -29,3 +29,14 @@ def create(request):
|
||||
else:
|
||||
form = PersonForm()
|
||||
return render(request, "person_form.html", {'form': form, 'action': "Neu anlegen"})
|
||||
|
||||
def edit(request, id):
|
||||
person = get_object_or_404(Person, id=id)
|
||||
if request.method == 'POST':
|
||||
form = PersonForm(request.POST, instance=person)
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
return redirect('members')
|
||||
else:
|
||||
form = PersonForm(instance=person)
|
||||
return render(request, 'person_form.html', {'form': form, 'action': 'Bearbeiten'})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user