我得到了这个资源,它工作正常,列出了员工的所有属性。在TastyPie资源上访问“服务器端”模型方法
class EmployeeResource(ModelResource):
journey = fields.ForeignKey(WorkJourney, 'work_journey')
class Meta:
queryset = Employee.objects.all()
resource_name = 'employee'
authentication = BasicAuthentication()
我writen对员工的模型类的方法,从一个员工列出了电话号码的(可怕的伊莫代码,我认为它应该是一个属性,但我不能改变它)。
@property
def phones(self):
return u'/'.join([self.personal_phones or u'', self.institutional_phones or u''])
关键是要编写访问模型方法,并列出结果与员工的属性的资源方法..