Hi all,
I want to change the default label for the None value in a
ModelChoiceField from the default '--------' to something more
meaningful in the context of my app.
After some research I tried subclassing the ModelChoiceField,
overriding the label_from_instance method like so:
class MyModelChoiceField(ModelChoiceField):
def label_from_instance(self, obj):
if obj:
return 'Something'
else:
return 'Nothing here'
which results in all the labels of object choices correctly changed to
'Something', but still '-------' for the None choice and not 'Nothing
here' as I would have expected. Any suggestions how I could change
that default value, preferrably even without introducing my own
subclass?
Regards,
Flo Ledermann
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---