Fix issue #66 on my own example, implementing get_val_txt(self, value) on my overriden field.

This commit is contained in:
apalazon 2013-10-29 10:23:26 +01:00
parent 3805f12717
commit e2cc63e69f

View file

@ -12,11 +12,21 @@ class GetSearchTestField(AutoSelect2MultipleField):
return True
def get_results(self, request, term, page, context):
"""
Just a trivial example.
Just a trivial example, with fixed values.
"""
res = [('Green Gold','Green Gold'),('Hulk','Hulk'),]
return (NO_ERR_RESP, False, res)
def get_val_txt(self, value):
"""
The problem of issue #66 was here. I was not overriding this.
When using AutoSelect2MultipleField you should implement get_val_txt in this case.
I think that this is because there should be an unique correspondence between
the referenced value and the shown value
In this particular example, the referenced value and the shown value are the same
"""
return unicode(value)
class GetModelSearchTestField(AutoModelSelect2MultipleField):
"""
Selects a department.