Django want to display help_text
Hello I would like to disp开发者_JAVA百科lay this help text in my model forms called alternate_id. However I seem to be having trouble with this. It might be what I have written in my response context.
forms.py
alternate_id = forms.CharField(label = 'Client no', max_length = 400, required = False, help_text = 'Valid wildcard search is in the format *XX, *XX*, XX*')
views.py
def search_item(request, client_id = 0):
# search form code
return render_to_response('search_items.html', {'form':form, 'form.alternate_id':form.alternate_id}, context_instance = RequestContext(request))
search_items.html
<form action="." method="post">
<fieldset class="model">
{{ form.as_p }}
{{ form.alternate_id.help_text }}
</fieldset>
Maybe you should try removing form.alternate_id':form.alternate_id
from your context dict. The form itself should contain the alternate_id field and its help text.
精彩评论