How to print a Django Forms many times with different id -


i have created form, multiple input option, populated queryset:

class testform(forms.modelform):     field = modelchoicefield(queryset=testtable.objects.all().order_by('desc1'))     class meta(object):         model = blockvalue         fields = () 

whithin same html form, want print testform many times.

in views.py possible create array of testform , print in template using loop?

you create formset , pass template:

 testformset = formset_factory(testform, extra=3,) 

then in view:

def test_form_view(request):     context = requestcontext(request)      if request.method == 'get':          formset = testformset()       return render_to_response('yourapp/test_form_template.html', {'formset': formset}, context) 

and in template:

{% form in formset %}     {{form.as_table}} {% endfor %} 

take @ docs more information


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -