django dropdown

Hello all,
I am new to django. I am trying to implement dropdown in the Form and stuck with it.I am not able to access the dropdown value in the HTML template. Please help me.

Models.py
RECYCLING_CHOICES = {
(“ENERGETIC”, “energetische Entsorgung”),
(“MATERIAL”, “stoffliche Entsorgung”),
(“DISPOSAL”, “Beseitigung”),
}

class WasteDetails(models.Model):
year = models.CharField(max_length=100)
waste_type = models.CharField(max_length=50)
disposer = models.CharField(max_length=50)
value = models.IntegerField(max_length=20)
recycling_method = models.CharField(
max_length=50, choices=RECYCLING_CHOICES, default=“DISPOSAL”
)
recycle_description = models.CharField(max_length=50)

Forms.py
class WastedataForm(forms.ModelForm):
class Meta:
model = WasteDetails
fields = [
“year”,
“waste_type”,
“disposer”,
“value”,
“recycling_method”,
“recycle_description”,
]

widget = forms.Select(choices=RECYCLING_CHOICES)

HTML template

{% extends ‘signupForm/base.html’ %}
{% block content %}
{% load static %}

Waste details

Please enter the details

{% csrf_token %}
Year
Waste type
            {{form.waste_type}}
          </div>
          <div class="col-md-12">
            <label for="disposer" class="form-label">Disposer</label>
           
            {{form.disposer}} 
          </div>
          <div class="col-md-12">
            <label for="value" class="form-label">Value</label>
            
            {{form.value}}
          </div>
          <div class="col-md-12">
            <label for="cfactor" class="form-label">Calculationfactor</label>
           {{form.calculation_factor}} 
          </div>
          <div class="col-md-12">
            <label for="recyclemethod" class="form-label">Recyclingmethod</label>
            <select id="recyclemethod" class="form-select" aria-label="Default select example">
                <option selected>Choose</option>
                {% for recycle in recycling_method %}
                <option value="{{recycle.recycle_method}}">{{recycle.choices}}</option>
                {% endfor %}
              </select>
          </div>
        
          <div class="col-md-12">
            <label for="description" class="form-label">Recyclingdescription</label>
            
            {{form.recycling_description}} 
          </div>
          <div class="col-12 pt-3 pb-3">
            <button type="submit" class="btn registerbtn mt-2">Submit</button>
          </div>
    </form>
</div>
<div class="col-md-6">
    <img src="{% static 'signupForm/img/sidepic.jpg' %}"
    alt="responsive-img" class="img-fluid rightpic"/>
</div>
{% endblock %}

Welcome @Hasireddy !

Basically, you’re not supposed to.

If you’re getting started, I suggest you just render the entire form as {{ form }}.

If you need to render individual fields, then see Rendering fields manually

But there’s no need, or benefit, to you manually rendering the options within a select list.

Thanks. But how can I access the values if I want to render a custom template?

Then you’re looking to create a custom widget template. See Widgets | Django documentation | Django and The form rendering API | Django documentation | Django

With Django, you want to get into the mindset that the templates are just data. All the real work is being done in the views, and the templates serve as a supporting role. Your pages generally will consist of many smaller pieces of html that are being assembled by the view.

yes I went through the documentation. There’s only little help about that. I am not able to figure it out what’s wrong with my code. Can you pls help?

I already told you.

What’s wrong with your code is that you’re trying to render the components within a form field individually.

Render the entire field as a “unit”.