Improve display of editions on purchase form
This commit is contained in:
parent
5f845f866e
commit
0814071a26
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue