[Answer]-Display Django URL list in template

1👍

From your view you need to pass it to template which can use it as list.

For example

view.py

def myview(request):
    catlist = request.GET.getlist('category')
    #do something
    ....
    # pass catlist to template and may be some other variables
    ctx = { 'catlist': catlist}
    return render_to_response('mytemplate.html', ctx,
                context_instance = RequestContext(request))

mytemplate.html

{% for cat in catlist %}
    <p> {{cat}} </p>
 {%endfor%}
👤Rohan

Leave a comment