Answer the question
In order to leave comments, you need to log in
How to filter queryset in template?
There are
techgroup models
class Techgroup(models.Model):
""" Group of technology """
name = models.CharField('group_name', max_length=32, unique=True)
class Technology(models.Model):
"""Technologies."""
tech_set = models.ForeignKey(Skillset, on_delete=models.CASCADE, related_name="skillset")
name = models.CharField('technology name', max_length=32, unique=True)
group = models.ForeignKey(Techgroup, on_delete=models.CASCADE, related_name="group")
class Employee(models.Model):
"""Employee information."""
user = models.OneToOneField(
settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='employee')
position = models.ManyToManyField(
Position, related_name='position', blank=True)
birth_date = models.DateField("date of birth", blank=True, null=True)
summary = models.TextField("summary", blank=True, default='')
skills = models.ManyToManyField(
Technology, through="Skill", verbose_name="skills", blank=True)
class AccountView(AuthorizedMixin, TemplateView):
template_name = "profile.html"
def get_context_data(self, **kwargs):
context = super(AccountView, self).get_context_data(**kwargs)
context['employee'] = Employee.objects.get(pk=self.kwargs['pk'])
context['skillset'] = Skillset.objects.all()
context['techgroup'] = Techgroup.objects.all()
return context
{% for group in techgroup.all %}
{{ group.name }}
{% for skill in employee.employee_skills.all %}
{% if skill.technology.group.name = ???????? %}
{{ {{skill.technology.name}} }}
{% endif %}
{% endfor %}
{% endfor %}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question