[Django] How to render a form 'n' number of times based on the dropdown selected integer in main Form

125 views
Skip to first unread message

Dilipkumar Noone

unread,
Dec 14, 2019, 2:22:59 PM12/14/19
to Django users

1.I have the below requirement in django to implement.

a)I have a main form with a few fields [text input fields,choice fields ] 

b)Based on the user input on integer field from the dropdown box in a template, i need to display few more fields waiting for the user input. Ex:If user selected an integer :3 i need to display another form 3 times containing few fields [ text input fields,choice fields] in the same html django template.[Say it is SubForm1]

c) Again based on dropdown selection in subform1

i need to display few more fields waiting for the user input. Ex:If user selected an integer :4 i need to display another form 3 times containing few fields [ text input fields,choice fields] in the same html django template.[Say it is SubForm2]


How to accomplish this .Can some one please share if any tutorial or any similar post already done at any place 

Basically i dont know much javascript/jquery .


can we accomplish this only using django forms & templates with out using javascript or jquery?



Dominick Del Ponte

unread,
Dec 15, 2019, 5:20:00 PM12/15/19
to django...@googlegroups.com
If you don't want to use JS you'll need to have the first form POST in order to send the number of forms to render to the backend. Then you should be able to use formsets with the 'extra' attribute to render multiple identical forms.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/da38e49c-c49a-4236-acf1-f79e4dfb678a%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages