I want to make a query, but I need to use the ObjectId, but do not know how 
to do.
The question is, have players and clubs and want to make a query to the 
players by the id of the club, to know how many players are from that club.

What I am trying to do is:

*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,

class ClubResource(resources.MongoEngineResource):
    
    class Meta:
        queryset = Club.objects.all()
        allowed_methods = ('get', 'post', 'put', 'delete')
        list_allowed_methods = ['get', 'post','put', 'delete']
        authorization = Authorization()
        resource_name = 'Club'

But when I do the query by id PlayerClub the club, it returns me []
So I guess I need to use the ObjectId, to make the query by id, but do not 
know how to put in the filtering.

Someone can help me?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to