From 3a3045be91b24a432c15e0de416368b4e35fb9b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kucharczyk?= Date: Fri, 20 Jan 2023 18:27:30 +0100 Subject: [PATCH] Sort form fields alphabetically Fixes #39 Fixes #40 --- CHANGELOG.md | 5 +++++ games/forms.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb25a24..b9492b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## Unreleased + +* Fixed + * Sort form fields alphabetically (https://git.kucharczyk.xyz/lukas/timetracker/issues/39, https://git.kucharczyk.xyz/lukas/timetracker/issues/40) + ## 0.2.5 / 2023-01-18 17:01+01:00 * New diff --git a/games/forms.py b/games/forms.py index 289aa20..01ce376 100644 --- a/games/forms.py +++ b/games/forms.py @@ -4,6 +4,8 @@ from games.models import Game, Platform, Purchase, Session class SessionForm(forms.ModelForm): + purchase = forms.ModelChoiceField(queryset=Purchase.objects.order_by("game__name")) + class Meta: model = Session fields = [ @@ -16,6 +18,9 @@ class SessionForm(forms.ModelForm): class PurchaseForm(forms.ModelForm): + game = forms.ModelChoiceField(queryset=Game.objects.order_by("name")) + platform = forms.ModelChoiceField(queryset=Platform.objects.order_by("name")) + class Meta: model = Purchase fields = ["game", "platform", "date_purchased", "date_refunded"]