我正在创建我的投资组合,我将其模板从Bootstrap模板处理到django项目中,我需要使模板中的技能部分来自名为“技能”的模型,以便以后可以添加更多技能。列出模板中的项目和字体图标,以便哪个模型字段可以处理?请注意,并非所有图标都是字体图标。这是模板中的代码:
技能
<div class="subheading mb-3">Programming Languages & Tools</div>
<ul class="list-inline dev-icons">
<li class="list-inline-item">
<i class="fab fa-html5"></i>
</li>
<li class="list-inline-item">
<i class="fab fa-css3-alt"></i>
</li>
<li class="list-inline-item">
<i class="fab fa-js-square"></i>
</li>
<li class="list-inline-item">
<i class="fab fa-sass"></i>
</li>
<li class="list-inline-item">
<i class="fab fa-python"></i>
</li>
<li class="list-inline-item">
<img class="img-fluid img-profile mx-auto mb-2" src="{% static 'img/sql.png' %}">
</li>
<li class="list-inline-item">
<img id="logo" src="{% static 'img/logo.png' %}">
</li>
</ul>
<div class="subheading mb-3">Duties & Responsibilities</div>
<ul class="fa-ul mb-0">
<li>
<i class="fa-li fa fa-check"></i>
Write reusable, testable, and efficient code.</li>
<li>
<i class="fa-li fa fa-check"></i>
Design and implement of low-latency, high-availability, and performant applications.</li>
<li>
<i class="fa-li fa fa-check"></i>
Integration of user-facing elements developed by front-end developers with server side logic.</li>
<li>
<i class="fa-li fa fa-check"></i>
Implementation of security and data protection</li>
<li>
<i class="fa-li fa fa-check"></i>
Integration of data storage solutions</li>
<li>
<i class="fa-li fa fa-check"></i>
Work collaboratively with design team to understand end user requirements to provide technical solutions and for the implementation of new software features</li>
</ul>
</div>
</section>
答案 0 :(得分:0)
您好,我建议您简单地创建一个具有Charfield字段的模型:
models.py:
class Skill(models.Model):
skill = models.CharField(max_length=255, blank=False, null=False, unique=True)
# name will make your skill easier to find in your admin
name = models.CharField(max_length=255, blank=False, null=False, unique=True)
def __str__(self):
return self.name
在您看来,您将能够收集所有技能:
def skills_view(request):
skills = Skills.objects.all()
return render(request, "template.html", {
'skills'=skills,
}
在模板中显示技能:
{% for skill in skills %}
<li class="list-inline-item">
<i class="{{skill.skill}}"></i>
</li>
{% endfor %}
如果我理解得很好,我会做这样的事情 在管理员中注册模型以增加您的技能