Open lb- opened 3 years ago
Another similar question, wanting a way to filter documents that are .csv
easily with a specific instance of a DocumentChooserBlock
https://stackoverflow.com/questions/69413317/is-there-a-way-to-filter-the-document-chooser-when-its-opened-from-a-particular
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