Improve display of editions on purchase form

This commit is contained in:
Lukáš Kucharczyk 2023-02-20 17:15:21 +01:00
parent 5f845f866e
commit 0814071a26
Signed by: lukas
SSH Key Fingerprint: SHA256:vMuSwvwAvcT6htVAioMP7rzzwMQNi3roESyhv+nAxeg
1 changed files with 6 additions and 1 deletions

View File

@ -20,8 +20,13 @@ class SessionForm(forms.ModelForm):
]
class EditionChoiceField(forms.ModelChoiceField):
def label_from_instance(self, obj) -> str:
return f"{obj.name} ({obj.platform}, {obj.year_released})"
class PurchaseForm(forms.ModelForm):
edition = forms.ModelChoiceField(queryset=Edition.objects.order_by("name"))
edition = EditionChoiceField(queryset=Edition.objects.order_by("name"))
platform = forms.ModelChoiceField(queryset=Platform.objects.order_by("name"))
class Meta: