diff --git a/app/costs/migrations/0002_alter_costs_costs_alter_costs_created.py b/app/costs/migrations/0002_alter_costs_costs_alter_costs_created.py new file mode 100644 index 0000000..1bc025d --- /dev/null +++ b/app/costs/migrations/0002_alter_costs_costs_alter_costs_created.py @@ -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'), + ), + ] diff --git a/app/costs/views.py b/app/costs/views.py index 620c270..89c1d1c 100644 --- a/app/costs/views.py +++ b/app/costs/views.py @@ -13,7 +13,7 @@ def costs_all(request): @login_required(login_url="account_login") -def costs_create(request): +def costs_create(request, id=None): if request.method == "POST": form = CostsForm(request.POST or None) if form.is_valid(): @@ -21,7 +21,10 @@ def costs_create(request): fs.user = request.user fs.save() return redirect("costs_all") - form = CostsForm() + if id: + form = CostsForm(initial={"id_bird":id}) + else: + form = CostsForm() context = {"form": form} return render(request, "costs/costs_create.html", context)