-
Notifications
You must be signed in to change notification settings - Fork 17
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
Get context of instance selector #19
Comments
I don't think there's a built-in or easy way to do it. I think the best approach would be to modify the widget's rendering to add an extra parameter onto the model-admin's url, then modify your model admin's index view to use the value in the param. Kinda related: #7 |
Thanks @markfinger. Do you have a pointer on how the widget would get access to the context of the page that is being edited? I am assuming that the page edit interface is a Django edit view... not sure if that is correct. |
I have a vague memory of looking into something similar a year or two back and found that the usual APIs for Wagtail's forms only provide minimal data to the widgets (eg: only a field's value, not the root object itself). That being said, I wouldn't be surprised if there's some undocumented method that could be used. Might be worth asking in the Wagtail Slack how to get access to the root object (eg: a page or other model instance) from a content panel. |
Thanks @markfinger. I will do that 👍 |
Not an issue, just a question:
I was wondering if there is a way to get the context in which the instance selector panel/modal is opened?
In my use case I would like to filter the instances displayed in the admin based on the current page in which the selector panel is opened. The model admin already comes with the filtering ability. All I would need from the context is the current pages id so that I can use that in the selectors
get_instance_selector_url
.The text was updated successfully, but these errors were encountered: