Django想要显示help_text

时间:2011-02-28 11:50:44

标签: python html django forms tags

您好我想在名为alternate_id的模型表单中显示此帮助文本。但是我似乎遇到了麻烦。这可能是我在回应背景下写的。

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>

1 个答案:

答案 0 :(得分:0)

也许您应该尝试从上下文字典中删除form.alternate_id':form.alternate_id。表单本身应包含alternate_id字段及其帮助文本。