79724260

Date: 2025-08-03 19:07:14
Score: 2.5
Natty:
Report link

What about using lambda function like this?

class FormCreatePlace(forms.ModelForm):    
    category = forms.ModelChoiceField(queryset=Category.objects.all())
    (...)

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.fields['category'].label_from_instance = lambda obj: obj.name
Reasons:
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Starts with a question (0.5): What
  • Low reputation (0.5):
Posted by: binaryEcon