How can I add help_text in django for a search field I am using in admin.py as:
class ProfileAdmin(admin.ModelAdmin):
list_display = ('First_Name','Last_Name','Registeration_No','University','Batch','Sex')
search_fields = ('First_Name','Last_Name','Registeration_No','University','Batch')
You can add this javascript in ModelAdmin
ModelAdmin will be like
add the custom_admin.js in
static/js/admin
directory.Answer just for myself!
attr
namedsearch_fields_hint
to myModelAdmin
subclass.placeholder="{{ cl.search_fields_hint }}
to the<input>
.self.search_fields_hint=search_fields_hint
to the__init__
.self.search_fields_hint
to ChangList.The easiest solution is with jquery:
$("#searchfield_id").attr('title', "Click here to search for someone")
Or you can add it directly to the HTML itself. The title shows up when you mouse over the search field.
You could either override Admin template
admin/search_form.html
to add help text;Or load a javascript file, which could find the dom node to insert the help text, in
ProfileAdmin.Media
, check the doc.