From 5339a725f250e11485d42a450eb8ea50bdc7a2ec Mon Sep 17 00:00:00 2001 From: "Edgar P. Burkhart" Date: Thu, 19 May 2022 20:33:36 +0200 Subject: [PATCH] Add form for transactions --- nummi/main/models.py | 7 +++++++ nummi/main/templates/main/transaction.html | 7 ++++++- nummi/main/urls.py | 3 +++ nummi/main/views.py | 12 ++++++++++-- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/nummi/main/models.py b/nummi/main/models.py index 57099a7..e15691b 100644 --- a/nummi/main/models.py +++ b/nummi/main/models.py @@ -1,5 +1,6 @@ import uuid from django.db import models +from django.forms import ModelForm class Transaction(models.Model): @@ -13,6 +14,12 @@ class Transaction(models.Model): return f"{self.date} {self.name}: {self.value}€" +class TransactionForm(ModelForm): + class Meta: + model = Transaction + fields = ["name", "description", "value", "date"] + + class Invoice(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) name = models.CharField(max_length=256) diff --git a/nummi/main/templates/main/transaction.html b/nummi/main/templates/main/transaction.html index 6cefd07..89a6225 100644 --- a/nummi/main/templates/main/transaction.html +++ b/nummi/main/templates/main/transaction.html @@ -1,4 +1,9 @@ -

{{ transaction }}

+
+ {% csrf_token %} + {{ form }} + +
+