Improve display of editions on purchase form

This commit is contained in:
Lukáš Kucharczyk 2023-02-20 17:15:21 +01:00
parent c1023bdcbc
commit 4086c078bd
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): 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")) platform = forms.ModelChoiceField(queryset=Platform.objects.order_by("name"))
class Meta: class Meta: