Django: Display form name in template with prefix -
i have looked around answer while no success. want name of form field prefix included. know how this?
example:
let's create form in views.py , include prefix this:
myform = someform(prefix="prefix") and pass template. if access form field within template directly {{ myform.username }} (notice prefix included):
<select id="id_prefix-username" name="prefix-username"> ... if manually create form tag , insert name, don't prefix it:
<input name="{{ myform.username.name }}"> will generate:
<input name="username"> notice how missing prefix. now, can achieve same result:
<input name="{{ myform.prefix }}-{{ myform.username.name }}"> but there must built in way this?
you can use html_name instead:
<input name="{{ myform.username.html_name }}"> that should add prefix needed
Comments
Post a Comment