Friday, June 28, 2013

Filter more than one level in the related field

Hi!
I have my application django-tastypie as BD and MongoDB
But I have a problem, it is unable to filter on more than one level, I will give an example to explain better.
I have the following:
class EntrepreneurResource (resources.MongoEngineResource):
    
     country = fields.ReferencedListField (of = 'Football.Resource.CountryResource'
          attribute = 'country', full = True, null = True)
    
     class Meta:
         queryset = Entrepreneur.objects.all ()
         allowed_methods = ('get', 'post', 'put', 'delete', 'patch')
         list_allowed_methods = ['get', 'post', 'put', 'delete', 'patch']
         authorization = Authorization ()
         filtering = {
             'id': ALL,
             'name': ALL,
             'country': ALL_WITH_RELATIONS,
             }

When I want to make a filter in the Entrepreneur country do the following:
http://localhost:8080/onpitch/api/v1/Entrepreneur/?country=51cd93e18774a713bc1f5763

And he returns the entrepreneur to have the country with that id

But now if I as you want, eg a filter like this:
http://localhost:8080/onpitch/api/v1/Entrepreneur/?country__name=Portugal

I do not return anything []

Someone can help me? What am I doing wrong?

--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment