Show form errors: view rewriting with methods

This commit is contained in:
Edgar P. Burkhart 2022-05-22 18:52:57 +02:00
parent 11c215e4d8
commit c3c328fdd6
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
8 changed files with 89 additions and 88 deletions

View file

@ -11,7 +11,7 @@
{% block body %}
<h1><i class="fa fa-{{ category.icon }}"></i> {{ category }}</h1>
<form action="{% url 'update_category' category.id %}" method="post">
<form action="{% url 'category' category.id %}" method="post">
{% csrf_token %}
{{ form }}
<div class="buttons">

View file

@ -1,5 +1,5 @@
{% for field in form %}
{{ field.errors }}
<label for="{{ field.id_for_label }}">{{ field.label }}</label>
{{ field }}
{% endfor %}
{% for field in form %}
{{ field.errors }}
<label for="{{ field.id_for_label }}">{{ field.label }}</label>
{{ field }}
{% endfor %}

View file

@ -29,7 +29,7 @@
{% for snap in snapshots %}
<div class="snapshot {% cycle 'w' 'g' %}">
<span class="date num center">
<a href="{% url 'snapshot' snap.date %}">{{ snap.date|date:"Y-m-d" }}</a>
<a href="{% url 'snapshot' snap.id %}">{{ snap.date|date:"Y-m-d" }}</a>
</span>
<span class="value num right">{% value snap.value %}</span>
<span class="diff num right">

View file

@ -21,7 +21,7 @@
{{ snapshot }}
</h1>
<form action="{% url 'update_snapshot' snapshot.id %}" method="post">
<form action="{% url 'snapshot' snapshot.id %}" method="post">
{% csrf_token %}
{{ form }}
<div class="buttons">

View file

@ -10,8 +10,9 @@
<h1>{{ transaction }}</h1>
{% spaceless %}
<form id="transaction" action="{% url 'update_transaction' transaction.id %}" method="post">
<form id="transaction" action="{% url 'transaction' transaction.id %}" method="post">
{% csrf_token %}
<input type="hidden" name="form" value="transaction" />
{{ form }}
<div class="buttons">
<a href="{% url 'del_transaction' transaction.id %}"><input type="button" value="Delete" class="btn del" /></a>
@ -35,8 +36,9 @@
</div>
<h3>Add Invoice</h3>
<form action="{% url 'add_invoice' transaction.id %}" method="post" enctype="multipart/form-data">
<form action="{% url 'transaction' transaction.id %}" method="post" enctype="multipart/form-data">
{% csrf_token %}
<input type="hidden" name="form" value="invoice" />
{{ invoice_form }}
<div class="buttons"><input class="btn" type="submit" value="Add Invoice" /></div>
</form>