How to use loop for requesting from html template in Django

43 views Asked by At

From html template say "createlist" I want to add link which actually request server to get one more object of image form to the "createlist" page. But when I run the code it actually happens only one time but I want maximum of 5 times this should be accepted. So here how I can use loop in html template so that it will get the request again and again up to the limit say 5. here is the template code -


    {% if morepicform %}
        {{ morepicform }}
    {% endif %}
    Want to add more pics? <a href="{% url 'createlist' 'morepic' %}" role="button">
    <img src="static/auctions/plus-circle-solid.svg" height="20px" width="20px"></a>

views function

def morepic(request, morepic=''):
    return render(request, "auctions/createlist.html",{
        "morepicform" : PictureForm(),
        "picform" : PictureForm(),
        "listform" : ListingForm()
    })

url pattern path function -

path("createlist/<str:morepic>", views.morepic, name="createlist")

Now how can I add the functionality of requesting "morepicform"?

0

There are 0 answers