Click here to Skip to main content
15,037,928 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The option is not visible in template file.

What I have tried:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<!--  form to take user input -->
    <div id="home" class="col-md-4" >
              <form class="input-form text-center">
                  <input type="text" placeholder="Enter your name" />


                  <select >{% for festive in festive_list %}
                      <option value=''>{{ festive}}</option>
                  </select>

                  <button type="button" id="btn" >Create</button>
                  {% endfor %}
              </form>
    </div>
</body>
</html>


views.py

from django.http import HttpResponse
from django.shortcuts import render
from django.template import loader


def index(request):
    #festival_list = ['Birthday','Holi','Diwali']
    festival_list = ["Birthday", 'Holi', 'Diwali']
    template = loader.get_template('polls/index.html')
    return render(request, 'polls/index.html', {'festival_list': festival_list})
Posted
Updated 2-Jul-20 17:27pm

1 solution

{% for festive in festival_list %}
{{ festive}}
{% endfor %}
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900