I am a newbie in Django , I make a Django form and show this in a HTML
. in this form I have a field products
, when a user selects a product, it shows all products.
Is there a way to implement a filter to search among all the products when the user writes the product name in the field?
The way to filter a list of Strings
in Python
that contains a specific substring, would be like this:
filtered_products = filter(lambda item: 'productName' in item , products)
Is this helpful? Notice that 'productName' string should be the variable that takes the string of your field.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.