Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing filter in get_item to find correct item #191

Open
TZanke opened this issue Jul 14, 2017 · 1 comment
Open

missing filter in get_item to find correct item #191

TZanke opened this issue Jul 14, 2017 · 1 comment

Comments

@TZanke
Copy link
Contributor

TZanke commented Jul 14, 2017

I have the following problem. I need the query_parameters to get the correct item in get_item. atm it does not look like if it is supported. So i implemented this workaround:

class CustomWidget(AutoComboboxSelectWidget):
    def update_query_parameters(self, qs_dict):
        self.lookup_class.custom_filter.update(qs_dict)
        super(AutoComboboxSelect, self).update_query_parameters(qs_dict)
class ABCLookup(ModelLookup):
    custom_filter = dict()
    def get_item(self, value):
        return self.get_queryset().filter(**self.custom_filter).get(number=value)

Works, but good idea? Any other solution?

@mlavin
Copy link
Owner

mlavin commented Jul 18, 2017

Hmm. get_item is used by the field's to_python method as well and the request isn't really available there. I'm not sure it can be that strictly enforced but maybe I'm forgetting something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants