0

细节 :

@localhost:8000/api/v1/user/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"
}

现在,如果我只想得到名字,我怎么能在美味的馅饼中做到这一点?

4

1 回答 1

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

使用“排除”属性。

于 2013-08-29T10:31:51.543 回答