Created
October 24, 2011 12:24
-
-
Save qoelet/1308901 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyCustomModelChoiceField(ModelChoiceField): | |
def label_from_instance(self, obj): | |
mapping = { | |
"A1": "B1", | |
"A2": "B2", | |
# ... etc | |
} | |
if obj.name in mapping.keys(): | |
return "New type - %s" % (mapping[obj.name]) | |
else: | |
# default back to original functionality | |
return smart_unicode(obj) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment