You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
LinkedField is super close but does not allow for a case where the URL param is fixed/static based on the Panel usage, something like this could be possible but does not really use any linked field at all.
Idea - Handling arbitrary widget attrs that generate URL params
Django has the widget.attrs approach for scenarios like this it seems (where we may not want to define a whole widget but just want to pass some dict down to its declaration/rendering).
Handling attrs does not work out of the box (e.g. PersonChooser(attrs={'data-country': 'AU' })) but it can be made to work without too much effort, it would be nice if it did though. From here the Widget class can append this value to the URL generated by get_choose_modal_url.
Maybe even going a step further and automatically add any URL params that are passed as attrs and prefixed with data-url- so no get_choose_modal_url modification needed (although, that is a bit magic).
Another option is to be more explicit and just allow PersonChooser(url_values={'country': 'AU' }), as long as the same params are also in the preserve_url_parameters on the view set, they could be used by get_unfiltered_object_list
The text was updated successfully, but these errors were encountered:
Example Use Case
Document
chooser block that will restrict file types based on some generic kwargs passed into the Block declarationdoc_block = RestrictedDocumentChooserBlock(accept="svg,md")
ORdoc_block = RestrictedDocumentChooserBlock(attrs={"data-url-accept": "svg,md"})
.Idea -
LinkedField
with a static valueLinkedField
is super close but does not allow for a case where the URL param is fixed/static based on thePanel
usage, something like this could be possible but does not really use any linked field at all.Idea - Handling arbitrary widget attrs that generate URL params
attrs
does not work out of the box (e.g.PersonChooser(attrs={'data-country': 'AU' })
) but it can be made to work without too much effort, it would be nice if it did though. From here the Widget class can append this value to the URL generated byget_choose_modal_url
.data-url-
so noget_choose_modal_url
modification needed (although, that is a bit magic).PersonChooser(url_values={'country': 'AU' })
, as long as the same params are also in thepreserve_url_parameters
on the view set, they could be used byget_unfiltered_object_list
The text was updated successfully, but these errors were encountered: