【发布时间】:2015-05-14 18:58:21
【问题描述】:
工作代码:
{% if request.user.manager.position != 'E' %}
{% endif %}
models.py
Position_choices = (('M', u'Manager'), ('E', u'Staff'), ('U', u'Other_staff'))
class Manager(models.Model):
...
position = models.CharField(max_length=1, choices=Position_choices, default='M')
用于项目的models.py
class Project(models.Model):
manager = models.ForeignKey(Manager, blank=True, null=True, related_name='manager_set')
Other_staff = models.ForeignKey(Manager, blank=True, null=True, related_name='staff_set')
Staff= models.ForeignKey(Manager, blank=True, null=True, related_name='otherstaff_set')
我在页面 html 上显示了一些块,具体取决于员工职位。但是以前只有一个员工,现在是2个。我试试:
{% if request.user.manager.position in ['E', 'U'] %}
结果:
Could not parse the remainder: '['E',' from '['E','
请您帮忙正确查询。
【问题讨论】: