mirror of
https://github.com/Hopiu/django-select2.git
synced 2026-04-07 07:30:58 +00:00
Fix issue #66 on my own example, implementing get_val_txt(self, value) on my overriden field.
This commit is contained in:
parent
3805f12717
commit
e2cc63e69f
1 changed files with 11 additions and 1 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue