individual costs function
This commit is contained in:
parent
5579f1a4df
commit
8461003129
2 changed files with 28 additions and 2 deletions
|
@ -0,0 +1,23 @@
|
||||||
|
# Generated by Django 4.2.3 on 2023-07-19 20:08
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('costs', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='costs',
|
||||||
|
name='costs',
|
||||||
|
field=models.DecimalField(decimal_places=2, default='0.00', max_digits=5, verbose_name='Betrag'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='costs',
|
||||||
|
name='created',
|
||||||
|
field=models.DateField(verbose_name='Gebucht am'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -13,7 +13,7 @@ def costs_all(request):
|
||||||
|
|
||||||
|
|
||||||
@login_required(login_url="account_login")
|
@login_required(login_url="account_login")
|
||||||
def costs_create(request):
|
def costs_create(request, id=None):
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
form = CostsForm(request.POST or None)
|
form = CostsForm(request.POST or None)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
|
@ -21,6 +21,9 @@ def costs_create(request):
|
||||||
fs.user = request.user
|
fs.user = request.user
|
||||||
fs.save()
|
fs.save()
|
||||||
return redirect("costs_all")
|
return redirect("costs_all")
|
||||||
|
if id:
|
||||||
|
form = CostsForm(initial={"id_bird":id})
|
||||||
|
else:
|
||||||
form = CostsForm()
|
form = CostsForm()
|
||||||
context = {"form": form}
|
context = {"form": form}
|
||||||
return render(request, "costs/costs_create.html", context)
|
return render(request, "costs/costs_create.html", context)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue