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">
- [Answered ]-Updating Records with image field in Django?
- [Answered ]-Zinnia Templates for List and detail view
- [Answered ]-Sphinx fails when generating documentation for Django project
- [Answered ]-Reduce queries to the same Django model when using Model.objects.all()
- [Answered ]-When trying to edit new profile is creating in django
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!’})
- [Answered ]-Migrate data from original User model to Custom User model in django 1.8
- [Answered ]-Deploying Django project on Linux
- [Answered ]-PyCharm console – no module named
Source:stackexchange.com