Filter

4 views
Skip to first unread message

Hélio Miranda

unread,
May 23, 2013, 6:58:07 AM5/23/13
to django...@googlegroups.com
Hi
I have the following code, in which the player have a reference to the club:
class Club(mongoengine.Document):
    ClubName = StringField()

class Player(mongoengine.Document):
    PlayerName = StringField()
    PlayerAge = IntField()
    PlayerClub = fields.ListField(fields.ReferenceField(Club,
                        reverse_delete_rule=CASCADE, dbref=False))

------------------------------
class PlayerResource(resources.MongoEngineResource):
    
    PlayerClub = fields.ReferencedListField(of='Rela.Resource.ClubResource',
         attribute='PlayerClub', full=True, null=True)
    
    class Meta:
        queryset = Player.objects.all()
        allowed_methods = ('get', 'post', 'put', 'delete')
        list_allowed_methods = ['get', 'post','put', 'delete']
        authorization = Authorization()
        resource_name = 'Player'
        filtering = {
            'PlayerClub': ALL_WITH_RELATIONS,
        }
 
    def determine_format(self, request): 
        return "application/json"


But after the club to see which players have, I wanted to make a filter to the players at the club that selected id, I returned only players that club. But as I am doing, I do not return anything.

For in my json is as follows:
[{"PlayerAge": 23, "PlayerClub": [{"ClubName": "Benfica", "
id": "519dd7b28774a704d4a97748", "resource_uri": "/Rela/api/v1/Club/519dd7b28774
a704d4a97748"}], "PlayerName": "Luis", "id": "519dd7b98774a704d4a97749"}]

someone can help me how can I make the filter?
Reply all
Reply to author
Forward
0 new messages