[Answered ]-What part of the website from Django/ Python to change to get a pre-written text in search bar?

2👍

Depending on your business needs, and what browsers you need to support, I’d like to recommend using the HTML input ‘placeholder’ attribute.

You would need to either override your forms init function and update the widget attrs dictionary from there or explicitly set the widget in your CharField declaration.

keywords = forms.CharField( widget=forms.TextInput(attrs={‘placeholder’: ‘Search for a tool’}))

0👍

Use the placeholder attribute of the input HTML tag:

<input type="text" name="keywords" placeholder="Enter a tool name">

0👍

You should take a loo into initial data for Forms.

form = Form(initial={'value': 'My Search!'})

In your case:
form = Search()
if request.method == ‘GET’:
form = Search(request.GET, initial={‘value’: ‘My Search!’})

Leave a comment