過濾器的用戶名有模型OraganisationUser:Django的查詢,以正確的格式
class OrganisationUser(CommonInfo):
active = models.BooleanField(default=True)
user = models.OneToOneField(User, related_name='organisation_user')
managers = models.ManyToManyField('self', related_name='employees_managed', null=True, default=None, blank=True, symmetrical=False)
approvers = models.ManyToManyField('self', related_name='approvees', null=True, default=None, blank=True, symmetrical=False)
organisation = models.ForeignKey(Organisation, related_name='employees')
user_details = models.OneToOneField('OrganisationUserDetails', null=True, blank=True)
super_admin = models.ForeignKey('self', related_name='organisation_employees', null=True, blank=True)
objects = OrganisationUserManager()
gems = models.PositiveIntegerField(default=0, null=True, blank=True)
rank = models.PositiveIntegerField(default=0, null=True, blank=True)
我寫了一個查詢在views.py過濾用戶名:
username = OrganisationUser.objects.filter(user = id)
print username
Its printing : [<OrganisationUser: nirmal>]
我想獲取尼爾默爾從上面的結果。