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

Is there any way to define queryset in InstanceSelectorBlock #7

Open
mubarak117136 opened this issue Jul 3, 2020 · 1 comment
Open

Comments

@mubarak117136
Copy link

hi,
i am trouble with a issue where i must need to use queryset in InstanceSelectorBlock.

class ProductBlock(InstanceSelectorBlock):
    def __init__(self, *args, **kwargs):
        target_model = kwargs.pop("target_model", "store.Product")
        super(ProductBlock, self).__init__(target_model=target_model, **kwargs)

Is there any way to initialize InstanceSelectorBlock with queryset.

thanks

@markfinger
Copy link
Contributor

Hi,

Not trivially. I think you'd need to punch through a few layers and configure a GET param in the url of the embed so your modeladmin could change the queryset.

Off the top of my head, you'd probably need to override widget on the InstanceSelectorBlock subclass, and provide your own InstanceSelectorWidget subclass that appends a param to the embed's url.

This seems like a pretty reasonable use-case. If you get it working, it'd be great if you could either paste some code here or even open a PR.

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