models.py
class Skill(models.Model):
title_choice = [
('LANGUAGE', 'Language'),
('FRAMEWORK', 'Framework')
]
title = models.CharField(max_length=15, choices=title_choice,
default='LANGUAGE')
name = models.CharField(max_length=50)
And the template(when compare with title) is
<h2 class="mb-5">Skills</h2>
{% for item in Skill %}
{% if item.title == "LANGUAGE" %}
<h3 class="mb-0">Programming Languages</h3>
<ul class="subheading mb-3">
<li class="list-inline-item">{{ item.name }}</li>
</ul>
{% elif item.title == "FRAMEWORK" %}
<div class="subheading mb-3">Frameworks</div>
<ul class="list-inline dev-icons">
<li class="list-inline-item">{{ item.name }}</li>
</ul>
{% endif %}
{% endfor %}
OUTPUT: output when I compare with title
When I try to compare the title from my model it doesn't show any data But when I compare the "name" with the database value it shows the correct output. template(when I compare with name)
<h2 class="mb-5">Skills</h2>
{% for item in Skill %}
{% if item.name == "Python" %}
<h3 class="mb-0">Programming Languages</h3>
<ul class="subheading mb-3">
<li class="list-inline-item">{{ item.name }}</li>
</ul>
{% elif item.name == "React" %}
<h3 class="mb-0">Frameworks</h3>
<ul class="subheading mb-3">
<li class="list-inline-item">{{ item.name }}</li>
</ul>
{% endif %}
{% endfor %}
OUTPUT:when I compare with name
I want to compare the value with title and show the results
{{item.title}}
?