python - Dynamically Add Field to Model Form Using Django -


i have model has fields address such street, city, state, zip. have created form allows user input values each of these. make user can press button, "add address" , each field repeated. use jquery add fields html, issue how these fields need represented in model?

ultimately, i'd take additional addresses , use them in search retrieve has of addresses user has input. or suggestions appreciated.

thanks vijay! couldn't mark yours answer (not sure why) link helped me.

since wanted fields repeat, put fields in table.

<form id="myform" method="post" action=""> {% form in formset.forms %}     <p> {{ form.nonduplicatingfield }}     <p> {{ fomr.anothernonduplicatingfield }}     <table border="0" cellpadding="0" cellspacing="0">         <tbody>             <tr>                <td>{{ form.duplicatingfield }}</td>                <td>{{ form.duplicatingfieldtwo }}</td>                <td>{{ form.duplicatingfieldthree }}</td>             </tr>         </tbody>     </table> {% endfor %} {{ formset.management_form }} </form> 

and included javascript (in addition jquery , jquery.formset)

<script type="text/javascript">     $(function() {         $('#myform tbody tr').formset();     }) </script> 

Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -