From e2cc63e69f16ba80b808b69d97e8d6a84f0a89ff Mon Sep 17 00:00:00 2001 From: apalazon Date: Tue, 29 Oct 2013 10:23:26 +0100 Subject: [PATCH] Fix issue #66 on my own example, implementing get_val_txt(self, value) on my overriden field. --- testapp/testapp/testmain/fields.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/testapp/testapp/testmain/fields.py b/testapp/testapp/testmain/fields.py index a7143f6..0e8e5aa 100644 --- a/testapp/testapp/testmain/fields.py +++ b/testapp/testapp/testmain/fields.py @@ -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.