如何在tastypie中获取Resource的属性

时间:2013-08-29 10:28:03

标签: django tastypie

详细信息:

@localhost:8000 / API / V1 /用户/ 1 /

给予:

{
    "date_joined": "2013-08-28T04:20:36.704342",
    "email": "a@a.com",
    "first_name": "",
    "id": 1,
    "is_active": true,
    "is_staff": true,
    "is_superuser": true,
    "last_login": "2013-08-29T01:18:07.163345",
    "last_name": "",
    "password": "pbkdf2_sha256$10000$EVKt9xEHWSaD$S/ipn3mqoSMBjo98D9wconcloape1eFvsu9mVoIm+KA=",
    "resource_uri": "/api/v1/user/1/",
    "username": "admin"
}

现在,如果我只想得到名字我怎么能用美味馅饼做到?

1 个答案:

答案 0 :(得分:0)

class MyResource(ModelResource):
    class Meta:
       queryset = User.objects.all()
       excludes = ['email', 'password', 'is_staff', 'is_superuser']

使用'排除'属性。